mirror of
https://github.com/home-assistant/core.git
synced 2026-08-07 05:46:41 +01:00
Migrate keenetic_ndms2 to call async_remove_device (#178054)
This commit is contained in:
@@ -70,11 +70,15 @@ async def async_unload_entry(
|
||||
_LOGGER.debug("Removing entity %s", entity_entry.entity_id)
|
||||
|
||||
ent_reg.async_remove(entity_entry.entity_id)
|
||||
if entity_entry.device_id:
|
||||
dev_reg.async_update_device(
|
||||
entity_entry.device_id,
|
||||
remove_config_entry_id=config_entry.entry_id,
|
||||
)
|
||||
# The tracker attaches to a device found by MAC, which may be
|
||||
# owned by another integration; only remove it if we own it.
|
||||
if (
|
||||
entity_entry.device_id
|
||||
and (device := dev_reg.async_get(entity_entry.device_id))
|
||||
is not None
|
||||
and device.config_entry_id == config_entry.entry_id
|
||||
):
|
||||
dev_reg.async_remove_device(device.id)
|
||||
|
||||
_LOGGER.debug("Finished cleaning device_tracker entities")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user