Skip to content

Apply light transition buffers in arrival order and for group members - #991

Open
zigpy-review-bot wants to merge 4 commits into
zigpy-bot/light-command-failure-coveragefrom
zigpy-bot/light-transition-buffer-ordering
Open

zigpy-review-bot wants to merge 4 commits into
zigpy-bot/light-command-failure-coveragefrom
zigpy-bot/light-transition-buffer-ordering

Conversation

@zigpy-review-bot

@zigpy-review-bot zigpy-review-bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the two edge cases left open in #988 after #989. Stacked on #990, which is stacked on #989.

  • A group member's on_off / level reports buffered while the group's transition runs were never applied: the group's completion only cleared the member's flag. They are now applied (and the member's state written) when the group transition ends, unless the member is still in a transition of its own, whose completion applies them.
  • An on_off=True report followed by current_level=0 in the same window resolved to on, because the zero level was applied before the on_off buffer. A zero level is now buffered as an on_off=False report, so the last report of the window wins regardless of its kind; a later non-zero level report restores whatever on_off report the zero replaced (an off command steps the level to 0 and back, a late 0 during a turn on is followed by the rising level), and a genuine on_off=False report is never cancelled by a level report.

Closes #988.

Changes

  • zha/application/platforms/light/__init__.py: the buffer application is extracted into _apply_transition_buffers, used by async_transition_complete and Light.transition_off; Light.transition_on drops a member's buffers left over from an earlier group transition (unless the member is in a transition of its own); a level 0 report goes into the on_off buffer (remembering what it replaced) instead of the brightness buffer.
  • tests/test_light.py: test_zero_level_and_on_off_reports_apply_in_arrival_order (ten orderings, in an off and an on window), test_group_member_reports_applied_when_group_transition_ends and test_group_member_buffer_dropped_when_group_transition_restarts. The arrival-order and member-apply tests fail without the change; the restart test guards the new apply path.

Testing

tests/test_light.py passes (47 tests) and the full suite passes, pre-commit passes.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.81%. Comparing base (3b5261a) to head (bfb3084).

Additional details and impacted files
@@                            Coverage Diff                            @@
##           zigpy-bot/light-command-failure-coverage     #991   +/-   ##
=========================================================================
  Coverage                                     97.81%   97.81%           
=========================================================================
  Files                                            61       61           
  Lines                                         10878    10896   +18     
=========================================================================
+ Hits                                          10640    10658   +18     
  Misses                                          238      238           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Light transition buffers: group members never applied, zero-level vs on_off ordering

1 participant