Properly tear down group entities on membership changes and group removal - #849
Draft
TheJulianJES wants to merge 1 commit into
Draft
Properly tear down group entities on membership changes and group removal#849TheJulianJES wants to merge 1 commit into
TheJulianJES wants to merge 1 commit into
Conversation
…oval Group entity teardown was previously skipped in three places, leaking member entity subscriptions (member entities kept references to dead group entities and kept invoking their debounced updates): - discover_group_entities cleared group_entities with a bare .clear() when a group dropped below 2 members, without calling on_remove() or unregister_group_entity(), and never removed a platform's group entity when that platform alone dropped below 2 eligible members (the stale entity remained registered and functional with a single backing member) - Gateway.group_removed popped the group without calling Group.on_remove(), unlike shutdown() and device_removed() - Group.on_remove() only removed the group entities themselves, leaving the member entity subscriptions in _entity_unsubs dangling unregister_group_entity() now also verifies the exact entity instance is registered, so a delayed removal task cannot unregister a recreated group entity with the same unique id.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #849 +/- ##
==========================================
+ Coverage 97.27% 97.28% +0.01%
==========================================
Files 55 55
Lines 10930 10954 +24
==========================================
+ Hits 10632 10657 +25
+ Misses 298 297 -1 ☔ View full report in Codecov by Harness. 🚀 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.
DRAFT. Description to be updated later. Just opening now, so I don't forget about this again.
I think this was related to the HA Core PR that creates "devices/services" for Zigbee groups:
Group entity teardown was previously skipped in three places, leaking member entity subscriptions (member entities kept references to dead group entities and kept invoking their debounced updates):
unregister_group_entity() now also verifies the exact entity instance is registered, so a delayed removal task cannot unregister a recreated group entity with the same unique id.