diff --git a/homeassistant/components/keenetic_ndms2/__init__.py b/homeassistant/components/keenetic_ndms2/__init__.py index 4f709ab98fec..154820234b49 100644 --- a/homeassistant/components/keenetic_ndms2/__init__.py +++ b/homeassistant/components/keenetic_ndms2/__init__.py @@ -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")