zigpy / zigpy-deconz

A library which communicates with Deconz radios for zigpy
GNU General Public License v3.0
85 stars 20 forks source link

Conbee II + ZHA, IKEA bulbs reported as on despite being off when using ZHA groups #120

Open comatose-tortoise opened 4 years ago

comatose-tortoise commented 4 years ago

System is: Intel-NUC / Home Assistant OS / HassOS 4.10 / Home Assistant (0.112.2) Conbee II firmware: deCONZ_ConBeeII_0x26580700.bin.GCF (but this problem was present also with deCONZ_ConBeeII_0x264a0700.bin.GCF) Extension USB cable to the Conbee II Conbee II operating on a channel far from nearby WiFi networks Zigbee devices are a number of different IKEA Tradfri lights and IKEA Tradfri power plugs

Problem: The IKEA bulbs (of several different types, GU10, E27, E14, etc) get the wrong status indication in the HA GUI. If I turn the bulbs off using ZHA groups, a number of them will become reported as on in the GUI, despite being off.

If I look in the GUI to see the history of the individual lights, it looks as if they were never turned off, but instead they turn off (status-wise, in the GUI) after some time, probably when their status is checked by HA.

In the logfile attached, all lights were turned off at 10:57:36, and did indeed turn off at this timepoint. Their status didn't turn off at this time though, looking in the GUI. Focusing on one room for simplicity, I can see that "light.hornlampa_2_vardagsrum" reported as off 11:04:48, "light.hornlampa_1_vardagsrum" 11:07:48, "ight.sideboardlampa_vardagsrum" 11:10:40, "light.hornlampa_3_vardagsrum" 11:17:41. This goes on for all the Tradfri lights. Sometimes it takes a really long time until they all turn off, like hours.

This causes problems with automations, among other things.

I'm speculating if this could be related to using zha_groups for the lights. I just turned off two rooms of Tradfri lights using the "group switch button" in the GUI (i.e., turning them all off without the use of a zha_group). And all these lights reported as off immediately.

Logfile: https://pastebin.com/vcReQHS5

dmulcahey commented 4 years ago

This is because groups rely on attribute reports (state changes in HA) to update the state of the group. These bulbs don't report state per the spec. We need to solution this on the HA side (at least that's where I think it needs to be done).

Adminiuga commented 4 years ago

Should we debounce group entity service requests (turn off, turn on) and then schedule update of all member entities ?

dmulcahey commented 4 years ago

Not sure there is a need to debounce but the schedule idea is a good one. I still only want to do this based on a whitelist though. So that we aren’t doing it for devices that accurately report.

Adminiuga commented 4 years ago

And it's strange it takes to update as long as an hour. Attribute reporting on on change is supposed to be happening on 15 min interval. So even if there was no attr report on group command, I still expecting to see an attr report in 15 min window time.

Adminiuga commented 4 years ago

Debounce scheduling of the update based on group entry service calls, so we don't schedule too many updates if user flicks the group on)off in rapid succession in short period of time

Adminiuga commented 4 years ago

E.g turned group on and then turned group off after one second, should schedule only one round of member entity status updates

comatose-tortoise commented 3 years ago

This problem appears to be solved (I'm currently using 114.4)!

willtho89 commented 3 years ago

problem still active for me. According to https://github.com/basnijholt/adaptive-lighting/issues/10 the issue seems to be ongoing for several users.

Just for reference, some related issues i found: https://github.com/home-assistant/core/issues/39236 https://github.com/zigpy/zigpy-deconz/issues/140

I guess my issue is the same as #140, but i haven't had time to debug this. I can however reproduce the behavior in HA GUI.

willtho89 commented 3 years ago

I did some more testing with just individual lights and HA groups (instead of ZHA groups).

The devices themselves turn on/off reliably most of the time. In a few cases, some devices don't report their state directly after a state change. Unfortunately this makes automations quite cumbersome :-(

Is this a problem with conbee II or rather a bug in zigpy itself?

ivanfrolovmd commented 3 years ago

I have different lights (Schneider Electric Switches) and RaspBee II as coordinator and I have the same problem - some lights randomly stay on or off in HA after issuing the toggle command for the group (although the whole group toggles successfully).

I've tried the same setup with zzh as coordinator and zigpy-znp module and I didn't have this problem. Statuses are reflected almost immediately and consistently on group toggles.