mirror of
https://github.com/home-assistant/core.git
synced 2026-08-24 10:13:52 -05:00
Update integrations to call async_remove_device (part 2) (#177963)
This commit is contained in:
committed by
Bram Kragten
parent
57d44f891f
commit
07f5bb8a0a
@@ -85,10 +85,7 @@ class LitterRobotDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||
(DOMAIN, device_id), self.config_entry.entry_id
|
||||
)
|
||||
if device:
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
self.previous_members = current_members
|
||||
|
||||
@override
|
||||
|
||||
@@ -183,9 +183,7 @@ async def async_setup_entry( # noqa: C901
|
||||
if hass_device := dev_reg.async_get_device_by_identifier(
|
||||
(DOMAIN, player_id), entry.entry_id
|
||||
):
|
||||
dev_reg.async_update_device(
|
||||
hass_device.id, remove_config_entry_id=entry.entry_id
|
||||
)
|
||||
dev_reg.async_remove_device(hass_device.id)
|
||||
|
||||
# register listener for new players
|
||||
def handle_player_added(event: MassEvent) -> None:
|
||||
|
||||
@@ -98,10 +98,7 @@ class OndiloIcoPoolsCoordinator(DataUpdateCoordinator[dict[str, OndiloIcoPoolDat
|
||||
self.config_entry.entry_id,
|
||||
)
|
||||
if device_entry:
|
||||
self._device_registry.async_update_device(
|
||||
device_id=device_entry.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
self._device_registry.async_remove_device(device_entry.id)
|
||||
|
||||
for pool_id in current_pools:
|
||||
pool_data = data[pool_id]
|
||||
|
||||
@@ -216,11 +216,7 @@ async def on_device_removed(
|
||||
if registered_device := registry.async_get_device_by_identifier(
|
||||
(DOMAIN, base_device_url), coordinator.config_entry.entry_id
|
||||
):
|
||||
# Detach only this entry; the registry deletes the device once none remain.
|
||||
registry.async_update_device(
|
||||
registered_device.id,
|
||||
remove_config_entry_id=coordinator.config_entry.entry_id,
|
||||
)
|
||||
registry.async_remove_device(registered_device.id)
|
||||
|
||||
if event.device_url in coordinator.devices:
|
||||
del coordinator.devices[event.device_url]
|
||||
|
||||
@@ -165,9 +165,7 @@ class PlugwiseDataUpdateCoordinator(DataUpdateCoordinator[dict[str, GwEntityData
|
||||
(DOMAIN, device_id), self.config_entry.entry_id
|
||||
)
|
||||
) is not None:
|
||||
device_reg.async_update_device(
|
||||
device_entry.id, remove_config_entry_id=self.config_entry.entry_id
|
||||
)
|
||||
device_reg.async_remove_device(device_entry.id)
|
||||
LOGGER.debug(
|
||||
"%s %s %s removed from device_registry",
|
||||
DOMAIN,
|
||||
|
||||
@@ -114,10 +114,7 @@ class SensiboDataUpdateCoordinator(DataUpdateCoordinator[SensiboData]):
|
||||
(DOMAIN, _id), self.config_entry.entry_id
|
||||
)
|
||||
if device:
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
self.previous_devices = current_devices
|
||||
|
||||
return data
|
||||
|
||||
@@ -248,9 +248,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry)
|
||||
(DOMAIN, device_id), entry.entry_id
|
||||
)
|
||||
if dev_entry is not None:
|
||||
device_registry.async_update_device(
|
||||
dev_entry.id, remove_config_entry_id=entry.entry_id
|
||||
)
|
||||
device_registry.async_remove_device(dev_entry.id)
|
||||
|
||||
entry.async_on_unload(
|
||||
client.add_device_lifecycle_event_listener(
|
||||
|
||||
@@ -201,10 +201,7 @@ class SolarLogDeviceDataCoordinator(DataUpdateCoordinator[dict[int, InverterData
|
||||
),
|
||||
self.config_entry.entry_id,
|
||||
):
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
_LOGGER.info("Device removed from device registry: %s", device.id)
|
||||
|
||||
# add new devices
|
||||
|
||||
@@ -122,9 +122,7 @@ async def _remove_device(
|
||||
return
|
||||
|
||||
_LOGGER.debug("Removing tasmota from device %s", mac)
|
||||
device_registry.async_update_device(
|
||||
device.id, remove_config_entry_id=config_entry.entry_id
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
|
||||
|
||||
def _update_device(
|
||||
|
||||
@@ -151,10 +151,7 @@ class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]):
|
||||
if device := device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, str(lock_id)), self.config_entry.entry_id
|
||||
):
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
|
||||
# add new locks
|
||||
if new_locks := current_locks - self._locks_last_update:
|
||||
|
||||
@@ -110,10 +110,7 @@ class TPLinkDataUpdateCoordinator(DataUpdateCoordinator[None]):
|
||||
(DOMAIN, device_id), self.config_entry.entry_id
|
||||
)
|
||||
if device:
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
child_coordinator = self._child_coordinators.pop(device_id, None)
|
||||
if child_coordinator:
|
||||
await child_coordinator.async_shutdown()
|
||||
|
||||
@@ -62,8 +62,5 @@ class TRMNLCoordinator(DataUpdateCoordinator[dict[int, Device]]):
|
||||
if entry := device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, str(device_id)), self.config_entry.entry_id
|
||||
):
|
||||
device_registry.async_update_device(
|
||||
device_id=entry.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(entry.id)
|
||||
return new_data
|
||||
|
||||
@@ -72,9 +72,6 @@ class UptimeRobotDataUpdateCoordinator(
|
||||
if device := device_registry.async_get_device_by_identifier(
|
||||
(DOMAIN, str(monitor_id)), self.config_entry.entry_id
|
||||
):
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
|
||||
return new_monitors
|
||||
|
||||
@@ -152,10 +152,7 @@ class WattsVisionHubCoordinator(DataUpdateCoordinator[dict[str, Device]]):
|
||||
(DOMAIN, device_id), self.config_entry.entry_id
|
||||
)
|
||||
if device:
|
||||
device_registry.async_update_device(
|
||||
device_id=device.id,
|
||||
remove_config_entry_id=self.config_entry.entry_id,
|
||||
)
|
||||
device_registry.async_remove_device(device.id)
|
||||
|
||||
@property
|
||||
def device_ids(self) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user