peter-murray / node-hue-api

Node.js Library for interacting with the Philips Hue Bridge and Lights
Apache License 2.0
1.19k stars 145 forks source link

Group Issues #108

Closed Phineas closed 7 years ago

Phineas commented 7 years ago

Hey,

When I try to set 1 light it's fine but when I try to set a group (philipsHue.setGroupLightState(0, state);), I get an error:


                throw e;
                ^
Api Error
    at HueApi._getGroupLightStateOptions (/Users/phineas/Desktop/dev/projects/node/parahouse/node_modules/node-hue-api/hue-api/index.js:1075:29)
    at HueApi.setGroupLightState (/Users/phineas/Desktop/dev/projects/node/parahouse/node_modules/node-hue-api/hue-api/index.js:366:24)
    at Object.<anonymous> (/Users/phineas/Desktop/dev/projects/node/parahouse/src/home.js:20:12)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.runMain (module.js:607:10)
    at run (bootstrap_node.js:382:7)```
peter-murray commented 7 years ago

The line you have hit is

deferred.reject(new ApiError("RGB state is not supported for groups yet"));

If you captured the error message, it would have been more clear. The problem is that RGB is not an easy thing to implement as it requires knowledge of the lights that are in group, as the RGB coordinates have to be converted for each different type of light into a HSL value.

Due to the fact you can combine things like a white light, and any number of different coloured hue devices, this would be a very thing to do as you have to make many calls to the Hue Bridge to be able to do this. It would be unlikely that you achieve this in a time frame where it would not be noticeable to the user, and each type of light would have to be activated differently.

To properly achieve this, the Hue APIs and applications tend to use scenes to achieve this type of activity, or try to use a HSL value instead, as that will be transformed by the bridge to the closest value that the light can handle, although I think you will still hit errors if there is a white light in the group.