mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Fix ZHA group removal entity registry cleanup (#124889)
* Fix ZHA cleanup entity registry parameter * Fix missing `gateway` when accessing coordinator device * Get `ZHADeviceProxy` for coordinator device
This commit is contained in:
parent
175ffe29f6
commit
7eeebf198b
@ -802,21 +802,24 @@ class ZHAGatewayProxy(EventBase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _cleanup_group_entity_registry_entries(
|
def _cleanup_group_entity_registry_entries(
|
||||||
self, zigpy_group: zigpy.group.Group
|
self, zha_group_proxy: ZHAGroupProxy
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Remove entity registry entries for group entities when the groups are removed from HA."""
|
"""Remove entity registry entries for group entities when the groups are removed from HA."""
|
||||||
# first we collect the potential unique ids for entities that could be created from this group
|
# first we collect the potential unique ids for entities that could be created from this group
|
||||||
possible_entity_unique_ids = [
|
possible_entity_unique_ids = [
|
||||||
f"{domain}_zha_group_0x{zigpy_group.group_id:04x}"
|
f"{domain}_zha_group_0x{zha_group_proxy.group.group_id:04x}"
|
||||||
for domain in GROUP_ENTITY_DOMAINS
|
for domain in GROUP_ENTITY_DOMAINS
|
||||||
]
|
]
|
||||||
|
|
||||||
# then we get all group entity entries tied to the coordinator
|
# then we get all group entity entries tied to the coordinator
|
||||||
entity_registry = er.async_get(self.hass)
|
entity_registry = er.async_get(self.hass)
|
||||||
assert self.coordinator_zha_device
|
assert self.gateway.coordinator_zha_device
|
||||||
|
coordinator_proxy = self.device_proxies[
|
||||||
|
self.gateway.coordinator_zha_device.ieee
|
||||||
|
]
|
||||||
all_group_entity_entries = er.async_entries_for_device(
|
all_group_entity_entries = er.async_entries_for_device(
|
||||||
entity_registry,
|
entity_registry,
|
||||||
self.coordinator_zha_device.device_id,
|
coordinator_proxy.device_id,
|
||||||
include_disabled_entities=True,
|
include_disabled_entities=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user