Skip to content

Ignore unavailable members when computing fan and switch group state - #911

Merged
TheJulianJES merged 2 commits into
devfrom
zigpy-bot/group-ignore-unavailable-members
Sep 29, 2026
Merged

TheJulianJES merged 2 commits into
devfrom
zigpy-bot/group-ignore-unavailable-members

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

Follow-up to #888, which stops an unavailable member from keeping a light group on. The other two group entities, FanGroup and SwitchGroup, derive their state from member states the same way and have the same problem: an unavailable member keeps reporting its last known state, so it still feeds into the group state.

  • SwitchGroup.update(): an unavailable member that was on kept the group on. Now only available members count towards the on state, same as Ignore unavailable members when computing light group state #888 does for lights.
  • FanGroup.update(): the group takes the percentage (or preset mode) of the first member that has one, so an unavailable member's stale speed could win over the reachable members, or keep the group on after every reachable member was turned off. Unavailable members are now skipped when picking the percentage/preset mode.

Neither group merges any capabilities from its members (unlike LightGroup, which merges supported color modes, effect lists, and mired ranges over all members), so there is nothing to keep merged over unavailable members here. LightGroup itself is left to #888.

Tests: added test_group_state_ignores_unavailable_members to tests/test_fan.py and tests/test_switch.py, modelled on the light test from #888. Both fail on dev and pass with this change. They take the member offline with update_available(False)/update_available(True), the path the availability checker uses.

Side note, not fixed here: setting on_network = True on a fan or switch member doesn't emit a state change for its entity (the setter calls update_available() before flipping _on_network, and their re-init finishes without suspending), which is why the tests don't use it like the light test does.

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (5d127a5) to head (abdff27).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev     #911   +/-   ##
=======================================
  Coverage   97.22%   97.22%           
=======================================
  Files          61       61           
  Lines       10654    10655    +1     
=======================================
+ Hits        10358    10359    +1     
  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.

@TheJulianJES
TheJulianJES merged commit 0d01d86 into dev Sep 29, 2026
10 checks passed
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