Search code examples
apiphilips-hue

Philips Hue command limitation


First of all I'm developing my own C# library for controlling Philips Hue, which means I'm not using the official SDK. (I'm guessing that the SDK will make sure you won't have any problems)

I'm a little confused about the limitation in the Core concepts page in the API, which states:

We can’t send commands to the lights too fast. If you stick to around 10 commands per second to the /lights resource as maximum you should be fine. For /groups commands you should keep to a maximum of 1 per second.

I intend to respect this limitation, but does the limitation still apply when you are performing GET requests on the /lights resource, or is it only for sending actual commands with PUT requests to /lights/<id>/state that change the state of the light? Same question goes for the /groups resource.

Also is it even possible to damage anything by sending too many requests, or will it just take longer to get all responses?

Edit:

My overall question is: How should I understand the API limitation?

A more specific sub-question is: Should I wait 100 ms before sending another /lights command, relative to when I received a response, or relative to when I sent the previous command?

Another sub-question is: Should I consider this limitation only when using PUT requests on e.g. /lights/<id>/state, or on all request types GET/PUT/POST/DELETE


Solution

  • I don't know if anything was changed in firmware updates, but I have discovered that the bridge might not be so simple as you would think, and that the API description isn't very clear. I've done a little testing while running firmware 01009914.

    The bridge seems to have some kind of queue of incoming commands. I sent {"bri":254} to a group 9 times and 1 final command of {"bri":1}. From the first command to when the light is actually dimmed, takes roughly 3-4 seconds. Each time I sent a command the bridge replied almost instantly with success token.

    I did the same small tests sending other commands, 10 of each JSON object:

    • {"bri":254} 3-4 seconds
    • {"on":true, "bri":254} 6-7 seconds
    • {"on":true, "bri":254, "alert":"none", "effect":"none"} 12-13 seconds

    This actually shows that each change of attributes takes roughly 0.3 seconds for the bridge to handle.

    I will claim that for each attribute we change, the bridge takes about 300 ms to finish, and the limitation of commands should be understood as: As long as you stick with changing one attribute of a group each second, you should be fine.

    Note: I only tried with one group consisting of three lights, and I don't know if the bridge actually does have a queue of incoming commands, and in case it does have a queue, I don't know what the limit of items in it is.

    Edit:

    Now we have some official clarification of the Hue System Performance.