Migrate keenetic_ndms2 to call async_remove_device (#178054)

This commit is contained in:
Erik Montnemery
2026-08-03 16:24:04 +02:00
committed by GitHub
parent 8f482bd7ec
commit 0a263fd35d
@@ -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")