feat: Bind: Retry poll on device timeout - #32626
Conversation
|
I think it's worth mentioning that these old Hue Atmel devices have been hit by terrible security flaws. While known ones were presumably patched (assuming users updated firmware), between that and the fact they are old, I don't think these should be "promoted" or that we should spend much time on fixing or working around their other flaws. They are clearly no good on multiple fronts, and cause for great concerns... 馃槹 About the PR itself, need to dig deeper in how that works out in practice with the potential for multi-timeouts, the delays and the debouncing. It mixes several timer-based aspects. At first glance, I'd say that at least introduces a bigger potential for concurrency & race issues (was present before but less likely with single-await). |
@Nerivec I see where you coming from and share your concerns. These "older" Hue fixtures also do not feature install codes, making them overall less secure.
I tried keeping concurrency issues in mind and took inspiration from existing retry mechanisms in Z2M. Edit: IMHO, devices powered by anything below a EFR32MG21 can't be recommended for serious deployments. Sadly, getting such details before purchasing isn't trivial... |
|
Since this is very specific for a certain device (Hue Atmel), I think it's better to handle this in the device definition |
@Koenkk Well, it's a generic retry mechanism that should work with every light that's too slow or misbehaving. 馃槉 |
|
It doesn't solve what I mentioned before though. We're going to see concurrency & race condition problems with this. Probably already have a few (debounce vs potential timeout), but limited due to letting the poll timings basically do the "retry" (eventually). |
@Nerivec Guess I'll have to fixed that then. 馃槄
But there's no "retry" for single command (OnOff, Scene, etc.) actions...
See above. |
I meant the logic re-runs every time we see a message from the device, which should clear the stale state automatically (eventually). I don't think a retry is doable in current logic, at least not internally to the debounce; any increase in potential time-spent increases the risks mentioned. |
@Nerivec Sorry, but I'm not following... 馃槼 zigbee2mqtt/lib/extension/bind.ts Lines 570 to 577 in 756a824
That's good to know.
Valid point, certainly. Once the debounce fires and the first poll is issued, it's over anyways. What about introducing a sort of backlog outside the |
|
Ok, so I was able to capture what a missing poll response looks like in Wireshark:
As you can see, the yellow read command for current level gets an Here's my theory: Maybe we're requesting the brightness level too soon, while the fade off transition is still in progress..? |

As mentioned in #32078 (comment), Hue fixtures with Atmel-based PCBs tend to get overwhelmed quite quickly when controlled via bindings (for some reason).
Because these fixtures can't report their state at all, we have to poll them for updates.
So when a fixture doesn't respond in time, Z2M is left with a stale state in cache. No good. 馃槼
This PR adds a retry mechanism (with jitter) to work around this specific issue, giving fixtures up to
1500 msof rest before a second attempt is made.The number of total attempts per attribute is currently fixed at
2, but could be made configurable in the future.