dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.88k stars 483 forks source link

Changes to `execute_if_off` sometimes not honoured #6710

Open ebaauw opened 1 year ago

ebaauw commented 1 year ago

Describe the bug

When setting config/color/execute_if_off through the API, deCONZ sometimes fails to write Options. It seems the change is ignored by state engine: no messages in the log (except the wen socket notification), no Zigbee Write Attributes in the sniffer. Sometimes this happens for all lights, sometimes for some. Sometimes it works after restarting deCONZ.

Steps to reproduce the behavior

PUT a light config with body of {"color": {"execute_if_off": true}}

Expected behavior

Should work always.

Screenshots

n/a

Environment

deCONZ Logs

When it works, the DDF log seems normal:

Jan 28 21:15:16 pi5 deCONZ[20998]: 21:15:12:017 SC tick --> StateCallFunction
Jan 28 21:15:16 pi5 deCONZ[20998]: 21:15:12:018 writeZclAttribute, ep: 0x0B, cl: 0x0300, attr: 0x000F, type: 0x18, mfcode: 0x0000, expr: Item.val ? 0x01 : 0x00
Jan 28 21:15:16 pi5 deCONZ[20998]: 21:15:12:018 00:17:88:01:0b:1c:ff:75-0b/config/color/execute_if_off expression: Item.val ? 0x01 : 0x00 --> 1
...
Jan 28 21:15:30 pi5 deCONZ[20998]: 21:15:21:522 SC tick --> StateRead config/color/execute_if_off, 00:17:88:01:0b:1c:ff:75-0b
Jan 28 21:15:30 pi5 deCONZ[20998]: 21:15:21:635 00:17:88:01:0b:1c:ff:75-0b/config/color/execute_if_off expression: Item.val = (Attr.val & 0x01) !== 0 --> true
Jan 28 21:15:30 pi5 deCONZ[20998]: 21:15:21:636 SC config/color/execute_if_off: synced
Jan 28 21:15:30 pi5 deCONZ[20998]: 21:15:21:636 SC --> StateFinished
Jan 28 21:15:30 pi5 deCONZ[20998]: 21:15:21:637 SC state change finished: 00:17:88:01:0b:1c:ff:75-0b

Additional context

I noticed a while ago that changes for my Mueller light didn't stick, but didn't have the time to investigate. Now I also see reports from one of my users, see https://github.com/ebaauw/homebridge-deconz/issues/100#issuecomment-1407475554. And more extensive testing shows it sometimes doesn't work for my Hue lights either. Not sure if relevant, but execute_if_off has default true, so it should be written on startup.

SwoopX commented 1 year ago

@ebaauw Phew, that makes me nervous... However, it might be related to #6323, a state change is kept alive "just" for 3 mins. You might want to retest with the added attribute and raise the timeout. The state change eventually times out if the air is too crowded?