Harden device entity lifecycle and command forwarding#689
Open
Harden device entity lifecycle and command forwarding#689
Conversation
5e4503b to
25a3046
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #689 +/- ##
==========================================
+ Coverage 97.51% 97.55% +0.04%
==========================================
Files 62 62
Lines 10949 10975 +26
==========================================
+ Hits 10677 10707 +30
+ Misses 272 268 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces important improvements to entity and device lifecycle management in the Zigbee integration, focusing on robust cleanup, initialization, and manufacturer-specific command handling. The main goals are to prevent stale state accumulation, ensure proper error handling during entity and endpoint removal, and guarantee that manufacturer codes are correctly forwarded in cluster commands.
Entity and Device Lifecycle Improvements:
on_removecallbacks in platform entities, preventing a single callback failure from aborting entity cleanup and ensuring all tracked tasks are cancelled and removed properly (zha/application/platforms/__init__.py). [1] [2]zha/zigbee/device.py).async_initializepasses do not accumulate pending entities by clearing the pending list after each initialization, and keeping entity instances stable across re-initialization (zha/zigbee/device.py).INITIALIZEDif all endpoints initialize successfully (zha/zigbee/device.py). [1] [2]Cluster Command Handling:
issue_cluster_commandto correctly forward manufacturer codes in bothargsandparamsinvocation paths, ensuring manufacturer-specific commands are properly framed for compatibility and reliability (zha/zigbee/device.py).Testing Enhancements:
tests/test_device.py). [1] [2]These changes collectively strengthen the reliability and maintainability of device and entity management in the Zigbee integration, reducing lifecycle errors and improving support for manufacturer-specific device interactions.## Summary
Hardens device/entity lifecycle initialization and cluster command forwarding.
Failing tests addressed
tests/test_device.py::test_issue_cluster_commandtests/test_device.py::test_platform_entity_on_remove_callback_failure_does_not_abort_cleanuptests/test_device.py::test_async_initialize_does_not_grow_pending_entities_between_passestests/test_device.py::test_async_initialize_does_not_mark_initialized_if_endpoint_init_failstests/test_sensor.py::test_device_counter_sensorstests/test_sensor.py::test_device_unavailable_or_disabled_skips_entity_pollingtests/test_light.py::test_light_refreshVerification
pytest(branch-local targeted run): all listed tests pass.