mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Migrate withings to call async_remove_device (#178058)
This commit is contained in:
committed by
Bram Kragten
parent
8056d77379
commit
60b1325694
@@ -875,16 +875,10 @@ async def async_setup_entry(
|
||||
if old_devices:
|
||||
device_registry = dr.async_get(hass)
|
||||
for device_id in old_devices:
|
||||
# Several config entries can share this identifier, each owning its own
|
||||
# device registry entry, so only remove this entry's own device.
|
||||
for device in device_registry.devices.get_entries(
|
||||
identifiers={(DOMAIN, device_id)}
|
||||
if device := device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, device_id), entry.entry_id
|
||||
):
|
||||
if device.config_entry_id == entry.entry_id:
|
||||
device_registry.async_update_device(
|
||||
device.id, remove_config_entry_id=entry.entry_id
|
||||
)
|
||||
break
|
||||
device_registry.async_remove_device(device.id)
|
||||
current_devices.remove(device_id)
|
||||
|
||||
device_coordinator.async_add_listener(_async_device_listener)
|
||||
|
||||
Reference in New Issue
Block a user