Remove bridged matter devices when matter bridge is removed (#91995)

* Removes bridged matter devices when matter bridge is removed

* Didn't have the fetch the config entry since that is already provided to us

* Switched to a safer method of removing the child devices
pull/92081/head
Arturo 2023-04-26 13:44:40 -06:00 committed by GitHub
parent 2bbebeb925
commit 75be1b4ff9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -195,6 +195,17 @@ async def async_remove_config_entry_device(
if node is None: if node is None:
return True return True
if node.is_bridge_device:
device_registry = dr.async_get(hass)
devices = dr.async_entries_for_config_entry(
device_registry, config_entry.entry_id
)
for device in devices:
if device.via_device_id == device_entry.id:
device_registry.async_update_device(
device.id, remove_config_entry_id=config_entry.entry_id
)
matter = get_matter(hass) matter = get_matter(hass)
await matter.matter_client.remove_node(node.node_id) await matter.matter_client.remove_node(node.node_id)