How do you control a group via API?

Trying to control a switch group with:

{
  "intent": "write.resource.device",
  "data": [
    {
      "subjectId": "group.1408808474519089152",
      "resources": [
        {
          "resourceId": "4.1.85",
          "value": "1"
        }
      ]
    }
  ]
}

but getting error 302 when it’s a group and not a device. There’s nothing in the documentation :laughing:

its kinda frustrating because the debug interface on dev panel works just fine but it uses some other version of api without the signatures but with cookies sessions instead

{"did":"group.1408808474519089152","data":{"4.1.85":"1"},"appId":"xxxxxx","openId":"yyyyy","useServer":1}
1 Like

@roumor It seems you’re running into a bit of a challenge trying to use the API for controlling a switch group instead of an individual device. Unfortunately, the reference provided doesn’t specifically address API control of device groups, which might be why you’re encountering the 302 error.

Currently, the information we have indicates that device groups, especially those using ZigBee 3.0, can be localized if they’re connected to the same gateway, allowing for local control. However, specifics of API integration for groups aren’t covered, which may explain the lack of documentation you’re encountering.

I understand this can be frustrating, and I would encourage you to reach out to the community for shared experiences or additional insights. Your feedback also helps improve the documentation and support for features like this. If anyone else in the community has faced similar issues or has found a workaround, please feel free to chime in!

Right now the public API doesn’t support sending commands directly to group.* IDs. That’s why you’re getting the 302. The debug panel works because it uses an internal session-based API that isn’t documented. The usual workarounds are to either send the command to each device in the group individually, or trigger a scene that controls the whole group.

2 Likes