Skip to content

Reduce number of virtual entities#782

Draft
puddly wants to merge 6 commits into
zigpy:devfrom
puddly:puddly/fix-ignored-entity-binding
Draft

Reduce number of virtual entities#782
puddly wants to merge 6 commits into
zigpy:devfrom
puddly:puddly/fix-ignored-entity-binding

Conversation

@puddly
Copy link
Copy Markdown
Contributor

@puddly puddly commented Jun 2, 2026

This PR reduces the number of virtual entities by propagating some of the implicit attribute config to their respective entities. The few remaining virtual entities can be moved to quirks in the near future.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.42%. Comparing base (3a884dc) to head (62095b8).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #782      +/-   ##
==========================================
+ Coverage   97.41%   97.42%   +0.01%     
==========================================
  Files          50       50              
  Lines       10419    10463      +44     
==========================================
+ Hits        10150    10194      +44     
  Misses        269      269              

☔ View full report in Codecov by Sentry.
📢 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.

Comment on lines -835 to -844
async def async_initialize_cluster(self, cluster: zigpy.zcl.Cluster) -> None:
"""Mirror detection_interval into the sibling IAS Zone handler."""
interval = cluster.get("detection_interval", cluster.get(0x0102))
if interval is None:
return
ias_zone = getattr(cluster.endpoint, "ias_zone", None)
if ias_zone is None:
return
self.debug("Loaded detection interval at startup: %s", interval)
ias_zone.reset_s = int(interval)
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.

This logic was always weird to have inside of ZHA. We still need to keep it somewhere (and not just delete it completely). But I don't think we can restore reset_s on startup / appdb load entirely in quirks. __init__ won't have any cached attributes loaded, and I'm not sure where else this could be put to load on startup.

But maybe we can just add a "reset_after" property to the cluster, with it defaulting to the local reset_s attribute, but then override it with the attribute access to detection_interval in the Aqara quirk?
That way, we don't need to load reset_s right on startup / appdb load, but just when it's needed. And we always have the fresh value, so we can also remove the override when changing/writing the attribute (here). I think that's a bit cleaner in general.

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