diff --git a/homeassistant/components/simplisafe/__init__.py b/homeassistant/components/simplisafe/__init__.py index df648d618854..e11b47eeecc7 100644 --- a/homeassistant/components/simplisafe/__init__.py +++ b/homeassistant/components/simplisafe/__init__.py @@ -117,8 +117,9 @@ def _async_register_base_station( ) # Check for an old system ID format and remove it: - if old_base_station := device_registry.async_get_device( - identifiers={(DOMAIN, system.system_id)} # type: ignore[arg-type] + if old_base_station := device_registry.async_get_device_by_identifier( + (DOMAIN, system.system_id), # type: ignore[arg-type] + entry.entry_id, ): # Update the new base station with any properties the user might have configured # on the old base station: diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index 1eb9559a2b8f..09cea70fa99f 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -244,8 +244,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry) def handle_deleted_device(device_id: str) -> None: """Handle a deleted device.""" - dev_entry = device_registry.async_get_device( - identifiers={(DOMAIN, device_id)}, + dev_entry = device_registry.async_get_device_by_identifier( + (DOMAIN, device_id), entry.entry_id ) if dev_entry is not None: device_registry.async_update_device( @@ -587,7 +587,9 @@ def create_devices( if mac_connections: kwargs.setdefault(ATTR_CONNECTIONS, set()).update(mac_connections) if ( - device_registry.async_get_device({(DOMAIN, device.device.device_id)}) + device_registry.async_get_device_by_identifier( + (DOMAIN, device.device.device_id), entry.entry_id + ) is None ): kwargs.update( diff --git a/homeassistant/components/smhi/config_flow.py b/homeassistant/components/smhi/config_flow.py index 3ae60f8deab5..ff47320ce381 100644 --- a/homeassistant/components/smhi/config_flow.py +++ b/homeassistant/components/smhi/config_flow.py @@ -102,8 +102,8 @@ class SmhiFlowHandler(ConfigFlow, domain=DOMAIN): ) device_reg = dr.async_get(self.hass) - if device := device_reg.async_get_device( - identifiers={(DOMAIN, f"{old_lat}, {old_lon}")} + if device := device_reg.async_get_device_by_identifier( + (DOMAIN, f"{old_lat}, {old_lon}"), reconfigure_entry.entry_id ): device_reg.async_update_device( device.id, new_identifiers={(DOMAIN, f"{lat}, {lon}")} diff --git a/homeassistant/components/solarlog/coordinator.py b/homeassistant/components/solarlog/coordinator.py index a4489babbcd0..e6aa88ad45cf 100644 --- a/homeassistant/components/solarlog/coordinator.py +++ b/homeassistant/components/solarlog/coordinator.py @@ -194,13 +194,12 @@ class SolarLogDeviceDataCoordinator(DataUpdateCoordinator[dict[int, InverterData if did == removed_device[0]: device_name = dn break - if device := device_registry.async_get_device( - identifiers={ - ( - DOMAIN, - f"{self.config_entry.entry_id}_{slugify(device_name)}", - ) - } + if device := device_registry.async_get_device_by_identifier( + ( + DOMAIN, + f"{self.config_entry.entry_id}_{slugify(device_name)}", + ), + self.config_entry.entry_id, ): device_registry.async_update_device( device_id=device.id, diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index 9d4f9b006d8f..f0e91f6ff8de 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -125,8 +125,8 @@ async def async_setup_entry( player = coordinator.player _LOGGER.debug("Setting up media_player device and entity for player %s", player) device_registry = dr.async_get(hass) - server_device = device_registry.async_get_device( - identifiers={(DOMAIN, coordinator.server_uuid)}, + server_device = device_registry.async_get_device_by_identifier( + (DOMAIN, coordinator.server_uuid), entry.entry_id ) name = player.name diff --git a/homeassistant/components/steam_online/__init__.py b/homeassistant/components/steam_online/__init__.py index 335636df105c..182c0a789372 100644 --- a/homeassistant/components/steam_online/__init__.py +++ b/homeassistant/components/steam_online/__init__.py @@ -64,7 +64,9 @@ async def async_migrate_entry(hass: HomeAssistant, entry: SteamConfigEntry) -> b hass.config_entries.async_add_subentry(entry, subentry) dev_reg = dr.async_get(hass) - if device := dev_reg.async_get_device({(DOMAIN, entry.entry_id)}): + if device := dev_reg.async_get_device_by_identifier( + (DOMAIN, entry.entry_id), entry.entry_id + ): if TYPE_CHECKING: assert entry.unique_id dev_reg.async_update_device( diff --git a/homeassistant/components/tailscale/coordinator.py b/homeassistant/components/tailscale/coordinator.py index 61900935938f..971fd6b9b632 100644 --- a/homeassistant/components/tailscale/coordinator.py +++ b/homeassistant/components/tailscale/coordinator.py @@ -67,7 +67,9 @@ class TailscaleDataUpdateCoordinator(DataUpdateCoordinator[dict[str, Device]]): device_registry = dr.async_get(self.hass) for device_id in stale_device_ids: - device = device_registry.async_get_device(identifiers={(DOMAIN, device_id)}) + device = device_registry.async_get_device_by_identifier( + (DOMAIN, device_id), self.config_entry.entry_id + ) if device: LOGGER.debug("Removing stale device: %s", device_id) device_registry.async_remove_device(device.id) diff --git a/homeassistant/components/tedee/coordinator.py b/homeassistant/components/tedee/coordinator.py index d486efc240c2..ba194594ab8f 100644 --- a/homeassistant/components/tedee/coordinator.py +++ b/homeassistant/components/tedee/coordinator.py @@ -148,8 +148,8 @@ class TedeeApiCoordinator(DataUpdateCoordinator[dict[int, TedeeLock]]): _LOGGER.debug("Removed locks: %s", ", ".join(map(str, removed_locks))) device_registry = dr.async_get(self.hass) for lock_id in removed_locks: - if device := device_registry.async_get_device( - identifiers={(DOMAIN, str(lock_id))} + 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, diff --git a/homeassistant/components/tplink/coordinator.py b/homeassistant/components/tplink/coordinator.py index 7edd4b24ee78..5b326c4287a2 100644 --- a/homeassistant/components/tplink/coordinator.py +++ b/homeassistant/components/tplink/coordinator.py @@ -106,8 +106,8 @@ class TPLinkDataUpdateCoordinator(DataUpdateCoordinator[None]): ): device_registry = dr.async_get(self.hass) for device_id in stale_device_ids: - device = device_registry.async_get_device( - identifiers={(DOMAIN, device_id)} + device = device_registry.async_get_device_by_identifier( + (DOMAIN, device_id), self.config_entry.entry_id ) if device: device_registry.async_update_device( diff --git a/homeassistant/components/tradfri/diagnostics.py b/homeassistant/components/tradfri/diagnostics.py index 733657d749cf..92ed1b61f496 100644 --- a/homeassistant/components/tradfri/diagnostics.py +++ b/homeassistant/components/tradfri/diagnostics.py @@ -18,8 +18,8 @@ async def async_get_config_entry_diagnostics( device_registry = dr.async_get(hass) device = cast( dr.DeviceEntry, - device_registry.async_get_device( - identifiers={(DOMAIN, entry.data[CONF_GATEWAY_ID])} + device_registry.async_get_device_by_identifier( + (DOMAIN, entry.data[CONF_GATEWAY_ID]), entry.entry_id ), ) diff --git a/homeassistant/components/trmnl/coordinator.py b/homeassistant/components/trmnl/coordinator.py index 9066fc440cb7..e4aa2b93520b 100644 --- a/homeassistant/components/trmnl/coordinator.py +++ b/homeassistant/components/trmnl/coordinator.py @@ -59,8 +59,8 @@ class TRMNLCoordinator(DataUpdateCoordinator[dict[int, Device]]): if self.data is not None: device_registry = dr.async_get(self.hass) for device_id in set(self.data) - set(new_data): - if entry := device_registry.async_get_device( - identifiers={(DOMAIN, str(device_id))} + 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, diff --git a/homeassistant/components/tuya/coordinator.py b/homeassistant/components/tuya/coordinator.py index ba3f7115438e..da1aad100759 100644 --- a/homeassistant/components/tuya/coordinator.py +++ b/homeassistant/components/tuya/coordinator.py @@ -163,8 +163,8 @@ class DeviceListener(SharingDeviceListener): def async_remove_device(self, device_id: str) -> None: """Remove device from Home Assistant.""" device_registry = dr.async_get(self.hass) - device_entry = device_registry.async_get_device( - identifiers={(DOMAIN, device_id)} + device_entry = device_registry.async_get_device_by_identifier( + (DOMAIN, device_id), self._entry.entry_id ) if device_entry is not None: device_registry.async_remove_device(device_entry.id) diff --git a/homeassistant/components/twinkly/__init__.py b/homeassistant/components/twinkly/__init__.py index 313b64c899fd..ca61ba4357ab 100644 --- a/homeassistant/components/twinkly/__init__.py +++ b/homeassistant/components/twinkly/__init__.py @@ -64,8 +64,8 @@ async def async_migrate_entry(hass: HomeAssistant, entry: TwinklyConfigEntry) -> entity_entry.entity_id, new_unique_id=device_info["mac"] ) device_registry = dr.async_get(hass) - device_entry = device_registry.async_get_device( - identifiers={(DOMAIN, identifier)} + device_entry = device_registry.async_get_device_by_identifier( + (DOMAIN, identifier), entry.entry_id ) if device_entry: device_registry.async_update_device( diff --git a/homeassistant/components/twinkly/coordinator.py b/homeassistant/components/twinkly/coordinator.py index 17a67674179d..4f0c200c9700 100644 --- a/homeassistant/components/twinkly/coordinator.py +++ b/homeassistant/components/twinkly/coordinator.py @@ -105,8 +105,8 @@ class TwinklyCoordinator(DataUpdateCoordinator[TwinklyData]): def _async_update_device_info(self, name: str) -> None: """Update the device info.""" device_registry = dr.async_get(self.hass) - device = device_registry.async_get_device( - identifiers={(DOMAIN, self.data.device_info["mac"])}, + device = device_registry.async_get_device_by_identifier( + (DOMAIN, self.data.device_info["mac"]), self.config_entry.entry_id ) if device: device_registry.async_update_device( diff --git a/homeassistant/components/uptime_kuma/coordinator.py b/homeassistant/components/uptime_kuma/coordinator.py index a685ebce3531..915a4af274ac 100644 --- a/homeassistant/components/uptime_kuma/coordinator.py +++ b/homeassistant/components/uptime_kuma/coordinator.py @@ -128,8 +128,9 @@ def async_migrate_entities_unique_ids( # migrate device identifiers and update version device_reg = dr.async_get(hass) for monitor in metrics.values(): - if device := device_reg.async_get_device( - {(DOMAIN, f"{coordinator.config_entry.entry_id}_{monitor.monitor_name!s}")} + if device := device_reg.async_get_device_by_identifier( + (DOMAIN, f"{coordinator.config_entry.entry_id}_{monitor.monitor_name!s}"), + coordinator.config_entry.entry_id, ): new_identifier = { (DOMAIN, f"{coordinator.config_entry.entry_id}_{monitor.monitor_id!s}") @@ -139,8 +140,9 @@ def async_migrate_entities_unique_ids( new_identifiers=new_identifier, sw_version=coordinator.api.version.version, ) - if device := device_reg.async_get_device( - {(DOMAIN, f"{coordinator.config_entry.entry_id}_update")} + if device := device_reg.async_get_device_by_identifier( + (DOMAIN, f"{coordinator.config_entry.entry_id}_update"), + coordinator.config_entry.entry_id, ): device_reg.async_update_device( device.id, diff --git a/homeassistant/components/uptimerobot/coordinator.py b/homeassistant/components/uptimerobot/coordinator.py index 60e99339f648..a85d23e1178f 100644 --- a/homeassistant/components/uptimerobot/coordinator.py +++ b/homeassistant/components/uptimerobot/coordinator.py @@ -69,8 +69,8 @@ class UptimeRobotDataUpdateCoordinator( device_registry = dr.async_get(self.hass) for monitor_id in stale_ids: - if device := device_registry.async_get_device( - identifiers={(DOMAIN, str(monitor_id))} + 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, diff --git a/homeassistant/components/waqi/__init__.py b/homeassistant/components/waqi/__init__.py index 41b60a6bd823..e88438759b51 100644 --- a/homeassistant/components/waqi/__init__.py +++ b/homeassistant/components/waqi/__init__.py @@ -100,8 +100,8 @@ async def async_migrate_integration(hass: HomeAssistant) -> None: entities = er.async_entries_for_config_entry(entity_registry, entry.entry_id) if TYPE_CHECKING: assert entry.unique_id is not None - device = device_registry.async_get_device( - identifiers={(DOMAIN, entry.unique_id)} + device = device_registry.async_get_device_by_identifier( + (DOMAIN, entry.unique_id), entry.entry_id ) for entity_entry in entities: diff --git a/homeassistant/components/watts/coordinator.py b/homeassistant/components/watts/coordinator.py index ae6bdfc4e2ae..754e268d8c90 100644 --- a/homeassistant/components/watts/coordinator.py +++ b/homeassistant/components/watts/coordinator.py @@ -148,7 +148,9 @@ class WattsVisionHubCoordinator(DataUpdateCoordinator[dict[str, Device]]): for device_id in stale_device_ids: _LOGGER.info("Removing stale device: %s", device_id) - device = device_registry.async_get_device(identifiers={(DOMAIN, device_id)}) + device = device_registry.async_get_device_by_identifier( + (DOMAIN, device_id), self.config_entry.entry_id + ) if device: device_registry.async_update_device( device_id=device.id, diff --git a/homeassistant/components/wolflink/__init__.py b/homeassistant/components/wolflink/__init__.py index 1a94fc700194..93e8a0b2b944 100644 --- a/homeassistant/components/wolflink/__init__.py +++ b/homeassistant/components/wolflink/__init__.py @@ -168,7 +168,9 @@ def _reattach_device_to_hub( device_registry = dr.async_get(hass) entity_registry = er.async_get(hass) - device = device_registry.async_get_device(identifiers={(DOMAIN, str(device_id))}) + device = device_registry.async_get_device_by_identifier( + (DOMAIN, str(device_id)), source_entry.entry_id + ) if device is None: return diff --git a/homeassistant/components/xbox/__init__.py b/homeassistant/components/xbox/__init__.py index 76e10ba5d38b..2a294666640f 100644 --- a/homeassistant/components/xbox/__init__.py +++ b/homeassistant/components/xbox/__init__.py @@ -160,14 +160,18 @@ async def async_migrate_entry(hass: HomeAssistant, entry: XboxConfigEntry) -> bo ) hass.config_entries.async_add_subentry(entry, subentry) - if device := dev_reg.async_get_device({(DOMAIN, friend.xuid)}): + if device := dev_reg.async_get_device_by_identifier( + (DOMAIN, friend.xuid), entry.entry_id + ): dev_reg.async_update_device( device.id, remove_config_entry_id=entry.entry_id, add_config_subentry_id=subentry.subentry_id, add_config_entry_id=entry.entry_id, ) - if device := dev_reg.async_get_device({(DOMAIN, "xbox_live")}): + if device := dev_reg.async_get_device_by_identifier( + (DOMAIN, "xbox_live"), entry.entry_id + ): dev_reg.async_update_device( device.id, new_identifiers={(DOMAIN, client.xuid)} ) diff --git a/homeassistant/components/yolink/__init__.py b/homeassistant/components/yolink/__init__.py index c2404ea1419c..d491799b3561 100644 --- a/homeassistant/components/yolink/__init__.py +++ b/homeassistant/components/yolink/__init__.py @@ -80,8 +80,8 @@ class YoLinkHomeMessageListener(MessageListener): and msg_data.get("event") is not None ): device_registry = dr.async_get(self._hass) - device_entry = device_registry.async_get_device( - identifiers={(DOMAIN, device_coordinator.device.device_id)} + device_entry = device_registry.async_get_device_by_identifier( + (DOMAIN, device_coordinator.device.device_id), self._entry.entry_id ) if device_entry is None: return