Preserve discovery progress after an endpoint failure - #835
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #835 +/- ##
=======================================
Coverage 97.19% 97.19%
=======================================
Files 57 57
Lines 10560 10563 +3
=======================================
+ Hits 10264 10267 +3
Misses 296 296 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3680327 to
abed086
Compare
|
This is an interesting edge case... not sure how many folks would hit this in reality but after poking through it I figured it would be worth at least sharing it. Codex Suggested Follow-up plan: semantic group-control eligibility and retained-group reconciliationPR #835 is now intentionally limited to its original scope: endpoint-discovery error containment plus safe group-entity lifecycle cleanup when total or platform membership falls below quorum. The later experiment around group-control eligibility, per-endpoint counting, aggregate filtering, and retained-entity reconciliation has been removed from this PR and should be handled in a dedicated follow-up. This comment records the evidence and implementation plan so that work is not lost. Problem to solveZHA currently treats the existence of a light, fan, or switch platform entity on a member endpoint as a proxy for whether that endpoint should:
Those concepts are not equivalent. One endpoint may expose multiple same-platform entities, and a user-facing The removed experiment improved two things by counting one platform vote per endpoint and excluding configuration/diagnostic entities. However, Zigbee invariantsThe design should preserve these protocol facts:
Therefore, quorum should count each unique member endpoint at most once per platform. Tests should not model duplicate insertion of the same endpoint as two memberships. Captured-device evidenceThe complete current fixture corpus was scanned:
The 11 Groups-without-OnOff fixtures are:
Two distinct real captures, Three additional STANDARD Recommended eligibility designIntroduce one explicit semantic capability on platform entities. Naming can follow maintainer preference; the important behavior is: class PlatformEntity:
_attr_supports_group_control = True
@property
def supports_group_control(self) -> bool:
return self.entity_category is None and self._attr_supports_group_control
class ConfigurableAttributeSwitch(PlatformEntity):
_attr_supports_group_control = FalseThen:
This is preferable to importing and type-checking Why simpler heuristics are insufficient
The explicit capability makes the semantic contract reviewable instead of inferring it from discovery metadata. Retained group reconciliationAfter eligibility is defined correctly, direct member-add/remove handling should:
This is where The light minimum-transition reset belongs in the same follow-up. Required tests
Separate physical-groupcast questionThe corpus also contains eight The minimal follow-up should not silently reject those devices based only on JSON evidence. Original-signature enforcement should be an explicit design decision, preferably supported by hardware testing and an override mechanism for known non-conformant devices. Acceptance criteria and sequencing
Suggested implementation sequence:
|
abed086 to
103206a
Compare
An exception while discovering one endpoint closes
Device.discover_entities()and loses every later endpoint. Catch at the endpoint boundary, log the failing endpoint, retain entities already yielded, and continue with the next endpoint. A regression test demonstrates partial results plus a later endpoint surviving the failure.Updated replacement for the endpoint-resilience part of #691. The overlapping group-teardown changes have been removed in favor of #849; this PR does not depend on it. It does not attempt to resume the failed endpoint's closed generator.
Validation against
devat66603431339afe37fa0048b70ff31d77dceb8f95: Python 3.12 full suite, 1383 passed, coverage above the 95% project gate; full pre-commit (codespell, Ruff, formatting, mypy, lock check) passed. Relevant regression checks fail on the unchanged base. GitHub CI for Python 3.12/3.13/3.14 is reported separately on the PR.