ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
134 stars 7 forks source link

Adaptive lightning disabled after lightbulb gets unreachable #68

Closed ursusHU closed 2 years ago

ursusHU commented 2 years ago

When turning off the bulbs via wall switch, after a while the bulb gets unreachable, and the plugin disables the adaptive lighting. Is this not implemented yet, or just missed a setting? Thanks in advance.

[17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: request 931: PUT /lights/21/state {"ct":331} [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: warning: request 931: api error 202: resource, /lights/21/state, is not modifiable. Device is not reachable. [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: request 932: PUT /lights/24/state {"ct":331} [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: warning: request 932: api error 202: resource, /lights/24/state, is not modifiable. Device is not reachable. [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: request 933: PUT /lights/25/state {"ct":331} [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: warning: request 933: api error 202: resource, /lights/25/state, is not modifiable. Device is not reachable. [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: request 934: PUT /lights/26/state {"ct":331} [17/08/2022, 23:15:11] [deCONZ] Phoscon-GW: warning: request 934: api error 202: resource, /lights/26/state, is not modifiable. Device is not reachable. [17/08/2022, 23:15:22] [deCONZ] Phoscon-GW Button: Programmable Switch Event: Single Press [17/08/2022, 23:15:41] [deCONZ] Guest Room Light Bulb: set Color Temperature from 331 mired to 330 mired [17/08/2022, 23:15:41] [deCONZ] Guest Room Light Bulb: Adaptive Lighting: disabled [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 2: set Color Temperature from 331 mired to 330 mired [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 2: Adaptive Lighting: disabled [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 3: set Color Temperature from 331 mired to 330 mired [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 3: Adaptive Lighting: disabled [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 4: set Color Temperature from 331 mired to 330 mired [17/08/2022, 23:15:41] [deCONZ] Living Room Spot 4: Adaptive Lighting: disabled

ebaauw commented 2 years ago

When turning off the bulbs via wall switch

Seriously, you don't want to be using traditional wall switches to power off smart lights.

the bulb gets unreachable, and the plugin disables the adaptive lighting.

Homebridge deCONZ computes a new colour temperature value due to adaptive lighting, and issues a PUT to change the light state in deCONZ. That fails because the light is unreachable. On next poll, Homebridge deCONZ sees that deCONZ reports the old colour temperature value, causing Homebridge deCONZ to think that another deCONZ client has changed the value (from new to old), and disables adaptive lighting. Incidentally, Homebridge Hue, in violation to the specs, keeps adaptive lighting active when the colour temperature value changes, so you won't see this issue there.

I'm not sure how best to fix this issue. I think Homebridge deCONZ should check the return status of the PUT and update the cached state back to the previous value when the PUT fails. This is tricky, because:

As a workaround, I could prevent disabling adaptive lighting on a changed colour temperature value while deCONZ reports the light unreachable.

However, the fix and/or workaround might not solve your issue. While adaptive lighting wouldn't be disabled when the light becomes unreachable, it probably would when you power-on the light. On power-on, the light changes its state to default power-on values. Depending on the brand and type, you might be able to set Power On Color Temperature to 65535 in the deCONZ GUI, to have the light power-on to the previous colour temperature value.

ursusHU commented 2 years ago

Seriously, you don't want to be using traditional wall switches to power off smart lights.

Well, actually I do, as part of the family still prefers to use them. They are physical switches upgraded with Shelly, so they also controlled via Homekit. In the homebridge-hue plugin there was a switch for wall switches, and it works great no reachability problems in Homekit. The default zigbee network is created with floor lamps, which are always on, so no delays visible. Earlier I also tried to use the shellys just to get an impulse from the switch and control the lights that way without turning them off, but it was very unreliable.

On power-on, the light changes its state to default power-on values. Depending on the brand and type, you might be able to set Power On Color Temperature to 65535 in the deCONZ GUI, to have the light power-on to the previous colour temperature value.

I have ikea bulbs. In the morning when I turn on a light for a few seconds it lights on with the evening setting (orange) and then gets white. Also the brightness value is kept. And of course during the evening it remains orange all night long even if it is turned off several times during the night. Maybe it is just ikea, but this worked out great for me.

Ps.: in homebridge-hue I have similar experience only when I restart the hb instance, then all lights loosing the adaptive lightning setting, and set to the latest used value.

https://user-images.githubusercontent.com/61931127/185586626-ac67877c-c5a4-44b6-a206-4a6faaa2ae9b.mov

ebaauw commented 2 years ago

As a workaround for now, adaptive lighting won't be disabled when deCONZ reports a new ct value. It remains tricky to recognise true ct changes from timing issues with Zigbee attribute reporting, causing ct to "jump".

Also made sure adaptive lighting is re-enabled after Homebridge, on first notification or poll of light state, instead of when Home app would check the adaptive lighting state.

Also improved the debouncing of multiple changes in quick succession, that would sometimes disable adaptive lighting.

Note to self: also noted an issue with draft DDF for Hue ZB3 lights that would incorrectly set colormode to xy on power-up.

ebaauw commented 2 years ago

In v0.0.22.