Skip to content

Conversation

@puddly
Copy link
Contributor

@puddly puddly commented Aug 14, 2025

This PR introduces two new events to the ZHA device object:

  • DeviceEntityAddedEvent(unique_id: str)
  • DeviceEntityRemovedEvent(unique_id: str)

And a new method:

  • recompute_entities()

recompute_entities() will emit the above events when entities are added/removed at runtime. I've added it to the main device discovery unit test to make sure that it's idempotent.

Future TODOs:

  • Re-interview devices after OTA.
  • Call recompute_entities on device rejoin to deal with devices that change modes.
  • Call recompute_entities after device reconfiguration button is clicked.
  • This is too expensive to call on every attribute update but it would be nice to figure out how to do this dynamically, to supersede the above manual calls?

@puddly puddly force-pushed the puddly/dynamic-entities branch from 8af5782 to 983586a Compare August 14, 2025 19:16
@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 93.75000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.98%. Comparing base (0fab9a3) to head (8662227).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
zha/zigbee/device.py 93.33% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #517      +/-   ##
==========================================
- Coverage   96.98%   96.98%   -0.01%     
==========================================
  Files          63       63              
  Lines       10559    10607      +48     
==========================================
+ Hits        10241    10287      +46     
- Misses        318      320       +2     

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

@puddly puddly force-pushed the puddly/dynamic-entities branch from d4118a6 to 8662227 Compare December 3, 2025 17:40
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.

1 participant