Ignore unavailable members when computing light group state - #888
Open
RReverser wants to merge 1 commit into
Open
Ignore unavailable members when computing light group state#888RReverser wants to merge 1 commit into
RReverser wants to merge 1 commit into
Conversation
`LightGroup.update()` derives on/off from every member's last reported state, with no availability check. A member that drops off the network while on keeps voting "on" indefinitely. The group then stays on even once every reachable member is off, and only clears once the stale member itself reports off again or the whole group entity is force refreshed some other way. `_make_members_assume_group_state()` already skips unavailable members when writing optimistic state after a command. `update()` should apply the same rule when reading it back.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, matches the PR description, and includes a targeted regression test covering the reported failure mode.
Pull request overview
This PR fixes LightGroup.update() so a light group’s computed on/off state ignores members that are currently unavailable, preventing a stale “on” report from an offline device from keeping the whole group marked on.
Changes:
- Filtered
on_statesinLightGroup.update()to include only members that are bothonandavailable. - Added a regression test ensuring an unavailable “on” member does not keep the group on after all reachable members are off, and that it counts again once it becomes reachable.
File summaries
| File | Description |
|---|---|
zha/application/platforms/light/__init__.py |
Updates group state derivation to exclude unavailable members from contributing to the “on” vote. |
tests/test_light.py |
Adds a test covering the offline-member-stale-state scenario for light groups. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #888 +/- ##
=======================================
Coverage 97.19% 97.19%
=======================================
Files 57 57
Lines 10560 10560
=======================================
Hits 10264 10264
Misses 296 296 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LightGroup.update()derives on/off from every member's last reported state, with no availability check. A member that drops off the network while on keeps voting "on" indefinitely. The group then stays marked as "on" even once every reachable member is off, and only clears once the stale member itself reports again or the whole group entity is force refreshed some other way._make_members_assume_group_state()already skips unavailable members when writing optimistic state after a command.update()should apply the same rule when reading it back.