Skip to content

Ignore unavailable members when computing light group state - #888

Open
RReverser wants to merge 1 commit into
zigpy:devfrom
RReverser:light-group-ignore-unavailable-members
Open

Ignore unavailable members when computing light group state#888
RReverser wants to merge 1 commit into
zigpy:devfrom
RReverser:light-group-ignore-unavailable-members

Conversation

@RReverser

Copy link
Copy Markdown

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.

`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.
Copilot AI lite review requested due to automatic review settings September 4, 2026 16:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_states in LightGroup.update() to include only members that are both on and available.
  • 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

codecov Bot commented Sep 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.19%. Comparing base (6660343) to head (990b483).

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.
📢 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants