From e95619f49709ce883ed79f28956271827dbbc89b Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 20 Oct 2026 17:52:27 +0200 Subject: [PATCH] Pass a DeviceInfo to async_get_or_create_device in integrations f-i (#187549) --- homeassistant/components/fibaro/__init__.py | 20 +++++----- homeassistant/components/firmata/__init__.py | 14 ++++--- homeassistant/components/fritz/coordinator.py | 38 ++++++++++-------- .../components/fritzbox/coordinator.py | 16 ++++---- .../components/google_health/__init__.py | 10 +++-- homeassistant/components/guardian/__init__.py | 21 +++++----- homeassistant/components/guntamatic/sensor.py | 12 +++--- homeassistant/components/habitica/__init__.py | 40 ++++++++++--------- .../components/hikvision/__init__.py | 12 +++--- homeassistant/components/hive/__init__.py | 16 ++++---- .../components/home_connect/coordinator.py | 24 ++++++----- homeassistant/components/homee/__init__.py | 16 ++++---- homeassistant/components/homekit/__init__.py | 20 +++++----- .../components/homematicip_cloud/hap.py | 8 ++-- .../components/hortimax/coordinator.py | 14 ++++--- homeassistant/components/hue/bridge.py | 38 ++++++++++-------- homeassistant/components/hue/v2/device.py | 28 +++++++------ .../hunterdouglas_powerview/__init__.py | 18 +++++---- .../components/hydrawise/__init__.py | 16 ++++---- .../components/iaqualink/__init__.py | 12 +++--- .../components/incomfort/coordinator.py | 16 ++++---- 21 files changed, 229 insertions(+), 180 deletions(-) diff --git a/homeassistant/components/fibaro/__init__.py b/homeassistant/components/fibaro/__init__.py index a2d4f4c507f8..1b22e1ddff87 100644 --- a/homeassistant/components/fibaro/__init__.py +++ b/homeassistant/components/fibaro/__init__.py @@ -325,16 +325,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: FibaroConfigEntry) -> No # register the hub device info separately as the hub has sometimes no entities fibaro_info = controller.read_fibaro_info() device_registry = dr.async_get(hass) - hub_device = device_registry.async_get_or_create( + hub_device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, controller.hub_serial)}, - serial_number=controller.hub_serial, - manufacturer=fibaro_info.manufacturer_name, - name=fibaro_info.hc_name, - model=fibaro_info.model_name, - sw_version=fibaro_info.current_version, - configuration_url=controller.get_frontend_url(), - connections={(dr.CONNECTION_NETWORK_MAC, fibaro_info.mac_address)}, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, controller.hub_serial)}, + serial_number=controller.hub_serial, + manufacturer=fibaro_info.manufacturer_name, + name=fibaro_info.hc_name, + model=fibaro_info.model_name, + sw_version=fibaro_info.current_version, + configuration_url=controller.get_frontend_url(), + connections={(dr.CONNECTION_NETWORK_MAC, fibaro_info.mac_address)}, + ), ) controller.link_main_devices_to_hub(hub_device.id) diff --git a/homeassistant/components/firmata/__init__.py b/homeassistant/components/firmata/__init__.py index 5003cd2c3161..d70d16790143 100644 --- a/homeassistant/components/firmata/__init__.py +++ b/homeassistant/components/firmata/__init__.py @@ -193,13 +193,15 @@ async def async_setup_entry( ) device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry.entry_id, - connections=set(), - identifiers={(DOMAIN, board.name)}, - manufacturer=FIRMATA_MANUFACTURER, - name=board.name, - sw_version=board.firmware_version, + device_info=dr.DeviceInfo( + connections=set(), + identifiers={(DOMAIN, board.name)}, + manufacturer=FIRMATA_MANUFACTURER, + name=board.name, + sw_version=board.firmware_version, + ), ) await hass.config_entries.async_forward_entry_setups( diff --git a/homeassistant/components/fritz/coordinator.py b/homeassistant/components/fritz/coordinator.py index 2ef42e9b7595..f9b0cf336323 100644 --- a/homeassistant/components/fritz/coordinator.py +++ b/homeassistant/components/fritz/coordinator.py @@ -196,15 +196,17 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]): self.hass.data[FRITZ_DATA_KEY].wol_buttons[self.unique_id] = set() device_registry = dr.async_get(self.hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - configuration_url=f"http://{self.host}", - connections={(dr.CONNECTION_NETWORK_MAC, self.mac)}, - identifiers={(DOMAIN, self.unique_id)}, - manufacturer="FRITZ!", - model=self.model, - name=self.config_entry.title, - sw_version=self.current_firmware, + device_info=dr.DeviceInfo( + configuration_url=f"http://{self.host}", + connections={(dr.CONNECTION_NETWORK_MAC, self.mac)}, + identifiers={(DOMAIN, self.unique_id)}, + manufacturer="FRITZ!", + model=self.model, + name=self.config_entry.title, + sw_version=self.current_firmware, + ), ) self.connection.clear_cache() @@ -651,16 +653,18 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]): # manually register device entry for new connected device device_registry = dr.async_get(self.hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - connections={(CONNECTION_NETWORK_MAC, dev_mac)}, - manufacturer="FRITZ!", - model="FRITZ!Box Tracked device", - name=device.hostname, - via_device_id=dr.async_get_device_id_by_identifier( - self.hass, - (DOMAIN, self.unique_id), - config_entry_id=self.config_entry.entry_id, + device_info=dr.DeviceInfo( + connections={(CONNECTION_NETWORK_MAC, dev_mac)}, + manufacturer="FRITZ!", + model="FRITZ!Box Tracked device", + name=device.hostname, + via_device_id=dr.async_get_device_id_by_identifier( + self.hass, + (DOMAIN, self.unique_id), + config_entry_id=self.config_entry.entry_id, + ), ), ) return True diff --git a/homeassistant/components/fritzbox/coordinator.py b/homeassistant/components/fritzbox/coordinator.py index 3aae66e66dac..f5ad5b719ed0 100644 --- a/homeassistant/components/fritzbox/coordinator.py +++ b/homeassistant/components/fritzbox/coordinator.py @@ -211,14 +211,16 @@ class FritzboxDataUpdateCoordinator(DataUpdateCoordinator[FritzboxCoordinatorDat and device.device_and_unit_id[0] not in new_data.devices ) ): - dr.async_get(self.hass).async_get_or_create( + dr.async_get(self.hass).async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - name=device.name, - identifiers={(DOMAIN, device.device_and_unit_id[0])}, - manufacturer=device.manufacturer, - model=device.productname, - sw_version=device.fw_version, - configuration_url=self.configuration_url, + device_info=dr.DeviceInfo( + name=device.name, + identifiers={(DOMAIN, device.device_and_unit_id[0])}, + manufacturer=device.manufacturer, + model=device.productname, + sw_version=device.fw_version, + configuration_url=self.configuration_url, + ), ) if ( diff --git a/homeassistant/components/google_health/__init__.py b/homeassistant/components/google_health/__init__.py index 63dad58d1a39..1c01fb4535b6 100644 --- a/homeassistant/components/google_health/__init__.py +++ b/homeassistant/components/google_health/__init__.py @@ -112,11 +112,13 @@ async def async_setup_entry( # it as their via_device parent even when only the device scope is granted # (the account-level sensors that would otherwise create it are gated on # different scopes). - dr.async_get(hass).async_get_or_create( + dr.async_get(hass).async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.entry_id)}, - manufacturer="Google", - entry_type=dr.DeviceEntryType.SERVICE, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.entry_id)}, + manufacturer="Google", + entry_type=dr.DeviceEntryType.SERVICE, + ), ) await hass.config_entries.async_forward_entry_setups(entry, _PLATFORMS) diff --git a/homeassistant/components/guardian/__init__.py b/homeassistant/components/guardian/__init__.py index acace22e41e1..4ad527dfee76 100644 --- a/homeassistant/components/guardian/__init__.py +++ b/homeassistant/components/guardian/__init__.py @@ -118,14 +118,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: GuardianConfigEntry) -> # Register the valve controller device up front so paired sensors can resolve # it as their via device when they are added: device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.data[CONF_UID])}, - manufacturer="Elexa", - name=f"Guardian valve controller {entry.data[CONF_UID]}", - sw_version=valve_controller_coordinators[API_SYSTEM_DIAGNOSTICS].data[ - "firmware" - ], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.data[CONF_UID])}, + manufacturer="Elexa", + name=f"Guardian valve controller {entry.data[CONF_UID]}", + sw_version=valve_controller_coordinators[API_SYSTEM_DIAGNOSTICS].data[ + "firmware" + ], + ), ) # Set up all of the Guardian entity platforms: @@ -227,7 +229,8 @@ class PairedSensorManager: # Remove the paired sensor device from the device registry (which will # clean up entities and the entity registry): dev_reg = dr.async_get(self._hass) - device = dev_reg.async_get_or_create( - config_entry_id=self._entry.entry_id, identifiers={(DOMAIN, uid)} + device = dev_reg.async_get_or_create_device( + config_entry_id=self._entry.entry_id, + device_info=dr.DeviceInfo(identifiers={(DOMAIN, uid)}), ) dev_reg.async_remove_device(device.id) diff --git a/homeassistant/components/guntamatic/sensor.py b/homeassistant/components/guntamatic/sensor.py index 5a2b8d804e01..802bdafe1dfc 100644 --- a/homeassistant/components/guntamatic/sensor.py +++ b/homeassistant/components/guntamatic/sensor.py @@ -364,12 +364,14 @@ async def async_setup_entry( serial = coordinator.data["serial"][0] device_registry = dr.async_get(hass) - main_device = device_registry.async_get_or_create( + main_device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, serial)}, - manufacturer="Guntamatic", - serial_number=serial, - sw_version=coordinator.data["version"][0], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, serial)}, + manufacturer="Guntamatic", + serial_number=serial, + sw_version=coordinator.data["version"][0], + ), ) entities: list[GuntamaticSensor] = [] diff --git a/homeassistant/components/habitica/__init__.py b/homeassistant/components/habitica/__init__.py index e0b62ee97696..823490114934 100644 --- a/homeassistant/components/habitica/__init__.py +++ b/homeassistant/components/habitica/__init__.py @@ -78,16 +78,18 @@ async def async_setup_entry( # Register the user device so children (party device) can resolve it # deterministically as their via_device parent before platforms are set up. - device_reg.async_get_or_create( + device_reg.async_get_or_create_device( config_entry_id=config_entry.entry_id, - entry_type=dr.DeviceEntryType.SERVICE, - manufacturer=MANUFACTURER, - model=NAME, - name=coordinator.data.user.profile.name, - configuration_url=( - URL(config_entry.data[CONF_URL]) / "profile" / config_entry.unique_id + device_info=dr.DeviceInfo( + entry_type=dr.DeviceEntryType.SERVICE, + manufacturer=MANUFACTURER, + model=NAME, + name=coordinator.data.user.profile.name, + configuration_url=( + URL(config_entry.data[CONF_URL]) / "profile" / config_entry.unique_id + ), + identifiers={(DOMAIN, config_entry.unique_id)}, ), - identifiers={(DOMAIN, config_entry.unique_id)}, ) party = coordinator.data.user.party.id @@ -103,17 +105,19 @@ async def async_setup_entry( if party is not None: # Register the party device so party member devices can resolve it # deterministically as their via_device parent. - device_reg.async_get_or_create( + device_reg.async_get_or_create_device( config_entry_id=config_entry.entry_id, - entry_type=dr.DeviceEntryType.SERVICE, - manufacturer=MANUFACTURER, - model=NAME, - name=hass.data[HABITICA_KEY][party].data.party.summary, - identifiers={(DOMAIN, f"{config_entry.unique_id}_{party!s}")}, - via_device_id=dr.async_get_device_id_by_identifier( - hass, - (DOMAIN, config_entry.unique_id), - config_entry_id=config_entry.entry_id, + device_info=dr.DeviceInfo( + entry_type=dr.DeviceEntryType.SERVICE, + manufacturer=MANUFACTURER, + model=NAME, + name=hass.data[HABITICA_KEY][party].data.party.summary, + identifiers={(DOMAIN, f"{config_entry.unique_id}_{party!s}")}, + via_device_id=dr.async_get_device_id_by_identifier( + hass, + (DOMAIN, config_entry.unique_id), + config_entry_id=config_entry.entry_id, + ), ), ) diff --git a/homeassistant/components/hikvision/__init__.py b/homeassistant/components/hikvision/__init__.py index a3ed40652abd..2efe2b40231e 100644 --- a/homeassistant/components/hikvision/__init__.py +++ b/homeassistant/components/hikvision/__init__.py @@ -160,12 +160,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: HikvisionConfigEntry) -> # Register the main device before platforms that use via_device device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, device_id)}, - name=device_name, - manufacturer="Hikvision", - model=device_type, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, device_id)}, + name=device_name, + manufacturer="Hikvision", + model=device_type, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/hive/__init__.py b/homeassistant/components/hive/__init__.py index 0210f03d274f..674978e31974 100644 --- a/homeassistant/components/hive/__init__.py +++ b/homeassistant/components/hive/__init__.py @@ -58,14 +58,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: HiveConfigEntry) -> None connections.add((dr.CONNECTION_NETWORK_MAC, mac)) device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, hub_data["device_id"])}, - connections=connections, - name=hub_data["hiveName"], - model=hub_data["deviceData"]["model"], - sw_version=hub_data["deviceData"]["version"], - manufacturer=hub_data["deviceData"]["manufacturer"], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, hub_data["device_id"])}, + connections=connections, + name=hub_data["hiveName"], + model=hub_data["deviceData"]["model"], + sw_version=hub_data["deviceData"]["version"], + manufacturer=hub_data["deviceData"]["manufacturer"], + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/home_connect/coordinator.py b/homeassistant/components/home_connect/coordinator.py index d069079eeb79..bf703c67267d 100644 --- a/homeassistant/components/home_connect/coordinator.py +++ b/homeassistant/components/home_connect/coordinator.py @@ -232,12 +232,14 @@ class HomeConnectRuntimeData: ) from error for appliance in appliances.homeappliances: - self.device_registry.async_get_or_create( + self.device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - identifiers={(DOMAIN, appliance.ha_id)}, - manufacturer=appliance.brand, - name=appliance.name, - model=appliance.vib, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, appliance.ha_id)}, + manufacturer=appliance.brand, + name=appliance.name, + model=appliance.vib, + ), ) new_coordinator = HomeConnectApplianceCoordinator( self.hass, @@ -454,12 +456,14 @@ class HomeConnectApplianceCoordinator(DataUpdateCoordinator[HomeConnectAppliance async def get_appliance_data(self) -> None: """Get appliance data.""" appliance = self.data.info - self.device_registry.async_get_or_create( + self.device_registry.async_get_or_create_device( config_entry_id=self._config_entry.entry_id, - identifiers={(DOMAIN, appliance.ha_id)}, - manufacturer=appliance.brand, - name=appliance.name, - model=appliance.vib, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, appliance.ha_id)}, + manufacturer=appliance.brand, + name=appliance.name, + model=appliance.vib, + ), ) if not appliance.connected: self.data.update(HomeConnectApplianceData.empty(appliance)) diff --git a/homeassistant/components/homee/__init__.py b/homeassistant/components/homee/__init__.py index 9f8b838f6c52..552ae88fd9b6 100644 --- a/homeassistant/components/homee/__init__.py +++ b/homeassistant/components/homee/__init__.py @@ -81,14 +81,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: HomeeConfigEntry) -> Non # create device register entry device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, homee.settings.mac_address)}, - identifiers={(DOMAIN, homee.settings.uid)}, - manufacturer="homee", - name=homee.settings.homee_name, - model="homee", - sw_version=homee.settings.version, + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, homee.settings.mac_address)}, + identifiers={(DOMAIN, homee.settings.uid)}, + manufacturer="homee", + name=homee.settings.homee_name, + model="homee", + sw_version=homee.settings.version, + ), ) # Remove devices that are no longer present in homee. diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 334046e04513..0d6f0639ca62 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -788,16 +788,18 @@ class HomeKit: identifier = (DOMAIN, self._entry_id, BRIDGE_SERIAL_NUMBER) self._async_purge_old_bridges(dev_reg, identifier, connection) accessory_type = type(self.driver.accessory).__name__ - dev_reg.async_get_or_create( + dev_reg.async_get_or_create_device( config_entry_id=self._entry_id, - identifiers={ - identifier # type: ignore[arg-type] - }, # this needs to be migrated as a 2 item tuple at some point - connections={connection}, - manufacturer=MANUFACTURER, - name=accessory_friendly_name(self._entry_title, self.driver.accessory), - model=accessory_type, - entry_type=dr.DeviceEntryType.SERVICE, + device_info=dr.DeviceInfo( + identifiers={ + identifier # type: ignore[arg-type] + }, # this needs to be migrated as a 2 item tuple at some point + connections={connection}, + manufacturer=MANUFACTURER, + name=accessory_friendly_name(self._entry_title, self.driver.accessory), + model=accessory_type, + entry_type=dr.DeviceEntryType.SERVICE, + ), ) @callback diff --git a/homeassistant/components/homematicip_cloud/hap.py b/homeassistant/components/homematicip_cloud/hap.py index 041fdf69ae2a..ba423d897ca1 100644 --- a/homeassistant/components/homematicip_cloud/hap.py +++ b/homeassistant/components/homematicip_cloud/hap.py @@ -170,11 +170,11 @@ class HomematicipHAP: if home.label != self.config_entry.unique_id else f"Home-{home.label}" ) - dr.async_get(self.hass).async_get_or_create( + dr.async_get(self.hass).async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - identifiers={(DOMAIN, home.id)}, - manufacturer="eQ-3", - name=hapname, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, home.id)}, manufacturer="eQ-3", name=hapname + ), ) @callback diff --git a/homeassistant/components/hortimax/coordinator.py b/homeassistant/components/hortimax/coordinator.py index 989ff9555357..c1ac9863d4c1 100644 --- a/homeassistant/components/hortimax/coordinator.py +++ b/homeassistant/components/hortimax/coordinator.py @@ -114,13 +114,15 @@ class HortimaxCoordinator(DataUpdateCoordinator[dict[str, HortimaxDeviceData]]): """ registry = dr.async_get(self.hass) for device in devices: - registry.async_get_or_create( + registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - identifiers={(DOMAIN, device.name)}, - manufacturer=MANUFACTURER, - name=device.label or device.name, - model="HortiMaX Pro", - serial_number=device.name, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, device.name)}, + manufacturer=MANUFACTURER, + name=device.label or device.name, + model="HortiMaX Pro", + serial_number=device.name, + ), ) @callback diff --git a/homeassistant/components/hue/bridge.py b/homeassistant/components/hue/bridge.py index b5c18385a603..6c84f7dcd8f6 100644 --- a/homeassistant/components/hue/bridge.py +++ b/homeassistant/components/hue/bridge.py @@ -203,14 +203,16 @@ def _async_register_bridge_device( """Add the bridge device to the device registry.""" device_registry = dr.async_get(hass) if api_version == 1: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)}, - identifiers={(DOMAIN, api.config.bridge_id)}, - manufacturer="Signify", - name=api.config.name, - model_id=api.config.model_id, - sw_version=api.config.software_version, + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)}, + identifiers={(DOMAIN, api.config.bridge_id)}, + manufacturer="Signify", + name=api.config.name, + model_id=api.config.model_id, + sw_version=api.config.software_version, + ), ) # create persistent notification if we found a bridge version # with security vulnerability @@ -229,17 +231,19 @@ def _async_register_bridge_device( "hue_hub_firmware", ) else: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)}, - identifiers={ - (DOMAIN, api.config.bridge_id), - (DOMAIN, api.config.bridge_device.id), - }, - manufacturer=api.config.bridge_device.product_data.manufacturer_name, - name=api.config.name, - model_id=api.config.model_id, - sw_version=api.config.software_version, + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, api.config.mac_address)}, + identifiers={ + (DOMAIN, api.config.bridge_id), + (DOMAIN, api.config.bridge_device.id), + }, + manufacturer=api.config.bridge_device.product_data.manufacturer_name, + name=api.config.name, + model_id=api.config.model_id, + sw_version=api.config.software_version, + ), ) diff --git a/homeassistant/components/hue/v2/device.py b/homeassistant/components/hue/v2/device.py index c81a02c362b2..62ed914f781e 100644 --- a/homeassistant/components/hue/v2/device.py +++ b/homeassistant/components/hue/v2/device.py @@ -44,21 +44,23 @@ async def async_setup_devices(bridge: HueBridge): """Register a Hue device in device registry.""" if isinstance(hue_resource, (Room, Zone, ServiceGroup)): # Register a Hue Room/Zone as service in HA device registry. - return dev_reg.async_get_or_create( + return dev_reg.async_get_or_create_device( config_entry_id=entry.entry_id, - entry_type=dr.DeviceEntryType.SERVICE, - identifiers={(DOMAIN, hue_resource.id)}, - name=hue_resource.metadata.name, - model=hue_resource.type.value.replace("_", " ").title(), - manufacturer=api.config.bridge_device.product_data.manufacturer_name, - via_device_id=dr.async_get_device_id_by_identifier( - hass, - (DOMAIN, api.config.bridge_device.id), - config_entry_id=entry.entry_id, + device_info=dr.DeviceInfo( + entry_type=dr.DeviceEntryType.SERVICE, + identifiers={(DOMAIN, hue_resource.id)}, + name=hue_resource.metadata.name, + model=hue_resource.type.value.replace("_", " ").title(), + manufacturer=api.config.bridge_device.product_data.manufacturer_name, + via_device_id=dr.async_get_device_id_by_identifier( + hass, + (DOMAIN, api.config.bridge_device.id), + config_entry_id=entry.entry_id, + ), + suggested_area=hue_resource.metadata.name + if hue_resource.type == ResourceTypes.ROOM + else None, ), - suggested_area=hue_resource.metadata.name - if hue_resource.type == ResourceTypes.ROOM - else None, ) # Register a Hue device resource as device in HA device registry. params = { diff --git a/homeassistant/components/hunterdouglas_powerview/__init__.py b/homeassistant/components/hunterdouglas_powerview/__init__.py index 8cf3d1b2d7ed..3beb66cc6271 100644 --- a/homeassistant/components/hunterdouglas_powerview/__init__.py +++ b/homeassistant/components/hunterdouglas_powerview/__init__.py @@ -67,15 +67,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: PowerviewConfigEntry) -> # manual registration of the hub device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, hub.mac_address)}, - identifiers={(DOMAIN, hub.serial_number)}, - manufacturer=MANUFACTURER, - name=hub.name, - model=hub.model, - sw_version=hub.firmware, - hw_version=hub.main_processor_version.name, + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, hub.mac_address)}, + identifiers={(DOMAIN, hub.serial_number)}, + manufacturer=MANUFACTURER, + name=hub.name, + model=hub.model, + sw_version=hub.firmware, + hw_version=hub.main_processor_version.name, + ), ) try: diff --git a/homeassistant/components/hydrawise/__init__.py b/homeassistant/components/hydrawise/__init__.py index a3465afd7941..19e706a6d205 100644 --- a/homeassistant/components/hydrawise/__init__.py +++ b/homeassistant/components/hydrawise/__init__.py @@ -80,14 +80,16 @@ async def async_setup_entry( entities would never be added. """ for controller in controllers: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry.entry_id, - identifiers={(DOMAIN, str(controller.id))}, - manufacturer=MANUFACTURER, - model=controller.hardware.model.description, - name=controller.name, - serial_number=controller.hardware.serial_number or None, - sw_version=controller.software_version or None, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, str(controller.id))}, + manufacturer=MANUFACTURER, + model=controller.hardware.model.description, + name=controller.name, + serial_number=controller.hardware.serial_number or None, + sw_version=controller.software_version or None, + ), ) # Register the controllers known at setup before the platforms construct diff --git a/homeassistant/components/iaqualink/__init__.py b/homeassistant/components/iaqualink/__init__.py index 7a4768390787..9489dd9496c1 100644 --- a/homeassistant/components/iaqualink/__init__.py +++ b/homeassistant/components/iaqualink/__init__.py @@ -146,12 +146,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: AqualinkConfigEntry) -> ) from svc_exception device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - name=system.name, - identifiers={(DOMAIN, system.serial)}, - manufacturer="Jandy", - serial_number=system.serial, + device_info=dr.DeviceInfo( + name=system.name, + identifiers={(DOMAIN, system.serial)}, + manufacturer="Jandy", + serial_number=system.serial, + ), ) for dev in devices.values(): diff --git a/homeassistant/components/incomfort/coordinator.py b/homeassistant/components/incomfort/coordinator.py index 641f48c267d8..6858e020ea57 100644 --- a/homeassistant/components/incomfort/coordinator.py +++ b/homeassistant/components/incomfort/coordinator.py @@ -137,14 +137,16 @@ class InComfortDataCoordinator(DataUpdateCoordinator[InComfortData]): # Register discovered gateway device # Respect this as it is. Maybe later... device_registry = dr.async_get(self.hass) - gateway_device = device_registry.async_get_or_create( + gateway_device = device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - identifiers={(DOMAIN, self.config_entry.entry_id)}, - connections={(dr.CONNECTION_NETWORK_MAC, self.config_entry.unique_id)} - if self.config_entry.unique_id is not None - else set(), - manufacturer="Intergas", - name="RFGateway", + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, self.config_entry.entry_id)}, + connections={(dr.CONNECTION_NETWORK_MAC, self.config_entry.unique_id)} + if self.config_entry.unique_id is not None + else set(), + manufacturer="Intergas", + name="RFGateway", + ), ) async_cleanup_stale_devices( self.hass,