Repository navigation
Apply on_off reports buffered during a light transition - #989
zigpy-review-bot wants to merge 2 commits into
Conversation
… "on" While the transitioning flag was set, an on_off=False report was buffered (as brightness 0) but an on_off=True report was discarded. When something other than the entity turned the light on within the window of a turn_off (a bound remote, or a cluster command sent through the ZHA service), the entity stayed off once the window ended, even with a non-zero level buffered. Buffer the on_off value itself and apply it in async_transition_complete; the last report in the window wins. The brightness buffer now holds brightness only. Co-authored-by: jasonmx <jason@merron.net>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #989 +/- ##
=======================================
Coverage 97.58% 97.58%
=======================================
Files 61 61
Lines 10870 10878 +8
=======================================
+ Hits 10607 10615 +8
Misses 263 263 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@zigpy-review-bot Check code coverage. If missing coverage is unrelated to this PR changes, possibly open another (stacked) PR for adding more coverage. Possibly also open (stacked) PR for "open items". Do review rounds. |
|
Coverage (full suite on the branch, 1567 tests): 97.6% overall, matching the Codecov report. The one miss that belonged to this PR was the buffered zero-level branch in The rest of the missing coverage is unrelated to this change. Stacked on top of this PR:
Other gaps I left alone: polling and the property fallbacks in the light platform, plus uncovered lines in discovery, helpers, virtual, decorators and async_. Review rounds ran on the stack with a Fable reviewer plus Copilot. Both found real problems in #991's first draft (a rising level after a level 0 ended the light off, stale member buffers after a group restart, and a spec-normal off sequence ending on). All were fixed and covered by tests, and the last round came back clean from both. Nothing was left open on #989 itself. |
Summary
While a light's transitioning flag is set, an
on_off=Falsereport is buffered (as brightness 0) but anon_off=Truereport is discarded. If something other than the entity turns the light on within the window of aturn_off(a remote bound to the bulb, or a cluster command sent throughzha.issue_zigbee_cluster_command), the entity stays off after the window ends, even though the light is on and its level was buffered.This buffers the
on_offvalue itself and applies it inasync_transition_complete(the last report in the window wins). The brightness buffer now holds brightness only.Follow-up to #767, which fixed the on/off-only case of #766. This covers the dimmable case reported by jasonmx in #767 (Hue LTA004 log). The change is taken from their branch, so they are credited as co-author.
Changes
zha/application/platforms/light/__init__.py: new_transition_on_off_buffer, reset inasync_transition_set_flag, filled inhandle_attribute_updatedfor bothonandoff, applied inasync_transition_complete(an appliedonalso clears_off_with_transition/_off_brightness).tests/test_light.py:test_on_off_report_during_off_transition_is_applied, parametrized for an external turn-on and for on-then-off within the window.Testing
tests/test_light.pypasses (24 tests), pre-commit (ruff, mypy, codespell) passes.Open items
Two edge cases from the review rounds are left as they were and tracked in #988: group members' buffers are never applied by the group's transition completion (already the case for the brightness buffer), and an
on_off=Truereport followed by acurrent_level=0report in the same window now resolves to on (the on_off report wins).