Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.23k stars 3.03k forks source link

Interpret unreachable Hue lights as off instead of previously known state #3856

Open TeamDman opened 3 months ago

TeamDman commented 3 months ago

Is your feature request related to a problem? Please describe.

When I turn the Hue light off from the physical lightswitch, the WLED strip remains on, but I want it to turn off with the light.

image

When I turn the Hue light off and on from the Hue app, the WLED strip properly matches the Hue bulb state.

Describe the solution you'd like

Check the reachable field next to the on field already being monitored via the Hue API.

Lightswitch off:

{
    "state": {
        "on": true,
        "reachable": false
...

Light switch on

{
    "state": {
        "on": true,
        "reachable": true
...

Since I'm not using a smart switch, the "on" field remains true.

https://github.com/Aircoookie/WLED/blob/acf6736afdc579e0bb498b9111e2b8ff7cbaab63/wled00/hue.cpp#L145

would probably become

 if (root["on"] && root["reachable"]) { 

Describe alternatives you've considered

I'm using time-controlled presets to run {"on":false} around my usual bedtime lol

Additional context

This would be a change to existing behaviour, perhaps a checkbox next to the existing Hue sync settings for interpret unreachable lights as off would be good?

I don't know if the reachable field is present on all Hue versions, or just my own

        "swversion": "1.104.2",

Looks like I'm behind a version, pls don't pwn me

blazoncek commented 3 months ago

Please make a PR when you have your solution working.