philips-hue

Change entertainment area via Hue Sync Box API


I am leveraging the Hue Sync Box API and I am able to control the settings like sync mode, and intensity. However, I am unable to change hueTarget to change the entertainment area in use.

This is my request: PUT https://hue_sync_box_ip/api/v1/execution

Headers:

'Content-Type': 'application/json; charset=utf-8'
'Authorization': 'Bearer <token>'

Body:

{"hueTarget": "/groups/c5cecc67-52e8-4f48-9d8d-433634daa9a1"}

The response I get is a 400 error with this body

{"code":15,"message":"Invalid Value"}

As per documentation, this is the problem:

The key exists and the value type matches, but it is not according to the specified format or range.

The documentation on hueTarget is this:

The method is put, the key is valid as per error message, the value type matches string, and I am following the /groups/<id> that is required on v1.

These are my groups. The id I've used matches the "Streaming" which is the group (entertainment area) to which I was trying to change.

   ...
    "hue": {
        "bridgeUniqueId": "001788FFFE6A3B07",
        "bridgeIpAddress": "<redacted>",
        "groupId": "ef023ba4-71bc-4b8b-a7ad-f86dd68356a4",
        "groups": {
            "ef023ba4-71bc-4b8b-a7ad-f86dd68356a4": {
                "name": "Living Room TV",
                "numLights": 5,
                "active": false
                "active": true
            },
            "c5cecc67-52e8-4f48-9d8d-433634daa9a1": {
                "name": "Streaming",
                "numLights": 3,
                "active": false
            }
        },
        "connectionState": "connected"
    },
  ...

I have also tried leveraging the hue endpoint with the same results:

This is my request: PUT https://hue_sync_box_ip/api/v1/hue

Headers:

'Content-Type': 'application/json; charset=utf-8'
'Authorization': 'Bearer <token>'

Body:

{
    "groups":
      {
          "c5cecc67-52e8-4f48-9d8d-433634daa9a1": {
              "active": true
          }
      }
}

The response I get is a 400 error with this body

{"code":15,"message":"Invalid Value"}

This matches the documentation: groups/<id>/ active Get, Put boolean.

I am also able to set the entertainment area manually on the app.

Any thoughts on what could be the issue here? I do think this code used to work at some point, but I am not sure as to confirm it for certain.


Solution

  • I've managed to make it work. Instead of sending /groups/<id> as per documentation, you should only send <id>.

    In other words, the body of the first call should be:

    {"hueTarget": "c5cecc67-52e8-4f48-9d8d-433634daa9a1"}
    

    instead of the original

    {"hueTarget": "/groups/c5cecc67-52e8-4f48-9d8d-433634daa9a1"}