diff --git a/homeassistant/components/airzone/__init__.py b/homeassistant/components/airzone/__init__.py index 1af84445d407..f566807010cd 100644 --- a/homeassistant/components/airzone/__init__.py +++ b/homeassistant/components/airzone/__init__.py @@ -111,38 +111,44 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirzoneConfigEntry) -> N if ws_data is not None: mac = ws_data.get(AZD_MAC, "") - ws_device = device_registry.async_get_or_create( + ws_device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, mac)}, - identifiers={(DOMAIN, f"{entry.entry_id}_ws")}, - manufacturer=MANUFACTURER, - model=ws_data.get(AZD_MODEL), - name=ws_data.get(AZD_FULL_NAME), - sw_version=ws_data.get(AZD_FIRMWARE), + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, mac)}, + identifiers={(DOMAIN, f"{entry.entry_id}_ws")}, + manufacturer=MANUFACTURER, + model=ws_data.get(AZD_MODEL), + name=ws_data.get(AZD_FULL_NAME), + sw_version=ws_data.get(AZD_FIRMWARE), + ), ) ws_device_id = ws_device.id for system_data in coordinator.data.get(AZD_SYSTEMS, {}).values(): system_id = system_data[AZD_ID] - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, f"{entry.entry_id}_{system_id}")}, - manufacturer=MANUFACTURER, - model=system_data.get(AZD_MODEL), - name=f"System {system_id}", - sw_version=system_data.get(AZD_FIRMWARE), - via_device_id=ws_device_id, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, f"{entry.entry_id}_{system_id}")}, + manufacturer=MANUFACTURER, + model=system_data.get(AZD_MODEL), + name=f"System {system_id}", + sw_version=system_data.get(AZD_FIRMWARE), + via_device_id=ws_device_id, + ), ) dhw_data: dict[str, Any] | None = coordinator.data.get(AZD_HOT_WATER) if dhw_data is not None: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, f"{entry.entry_id}_dhw")}, - manufacturer=MANUFACTURER, - model="DHW", - name=dhw_data.get(AZD_NAME), - via_device_id=ws_device_id, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, f"{entry.entry_id}_dhw")}, + manufacturer=MANUFACTURER, + model="DHW", + name=dhw_data.get(AZD_NAME), + via_device_id=ws_device_id, + ), ) # Register the parents before forwarding platforms, and keep them registered diff --git a/homeassistant/components/airzone_cloud/__init__.py b/homeassistant/components/airzone_cloud/__init__.py index 1ac5ee935738..2a3d5ceaa01a 100644 --- a/homeassistant/components/airzone_cloud/__init__.py +++ b/homeassistant/components/airzone_cloud/__init__.py @@ -70,28 +70,32 @@ def _async_register_devices( device_registry = dr.async_get(hass) for ws_id, ws_data in coordinator.data.get(AZD_WEBSERVERS, {}).items(): - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(dr.CONNECTION_NETWORK_MAC, ws_id)}, - identifiers={(DOMAIN, ws_id)}, - manufacturer=MANUFACTURER, - model="WebServer", - name=ws_data[AZD_NAME], - sw_version=ws_data[AZD_FIRMWARE], + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, ws_id)}, + identifiers={(DOMAIN, ws_id)}, + manufacturer=MANUFACTURER, + model="WebServer", + name=ws_data[AZD_NAME], + sw_version=ws_data[AZD_FIRMWARE], + ), ) for system_id, system_data in coordinator.data.get(AZD_SYSTEMS, {}).items(): - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, system_id)}, - manufacturer=MANUFACTURER, - model=system_data.get(AZD_MODEL), - name=system_data[AZD_NAME], - sw_version=system_data.get(AZD_FIRMWARE), - via_device_id=dr.async_get_device_id_by_identifier( - hass, - (DOMAIN, system_data[AZD_WEBSERVER]), - config_entry_id=entry.entry_id, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, system_id)}, + manufacturer=MANUFACTURER, + model=system_data.get(AZD_MODEL), + name=system_data[AZD_NAME], + sw_version=system_data.get(AZD_FIRMWARE), + via_device_id=dr.async_get_device_id_by_identifier( + hass, + (DOMAIN, system_data[AZD_WEBSERVER]), + config_entry_id=entry.entry_id, + ), ), ) diff --git a/homeassistant/components/axis/hub/hub.py b/homeassistant/components/axis/hub/hub.py index 3262bdba6c94..0bf5e7829798 100644 --- a/homeassistant/components/axis/hub/hub.py +++ b/homeassistant/components/axis/hub/hub.py @@ -73,15 +73,17 @@ class AxisHub: async def async_update_device_registry(self) -> None: """Update device registry.""" 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=self.api.config.url, - connections={(CONNECTION_NETWORK_MAC, self.unique_id)}, - identifiers={(DOMAIN, self.unique_id)}, - manufacturer=ATTR_MANUFACTURER, - model=f"{self.config.model} {self.product_type}", - name=self.config.name, - sw_version=self.fw_version, + device_info=dr.DeviceInfo( + configuration_url=self.api.config.url, + connections={(CONNECTION_NETWORK_MAC, self.unique_id)}, + identifiers={(DOMAIN, self.unique_id)}, + manufacturer=ATTR_MANUFACTURER, + model=f"{self.config.model} {self.product_type}", + name=self.config.name, + sw_version=self.fw_version, + ), ) # Setup and teardown methods diff --git a/homeassistant/components/bang_olufsen/__init__.py b/homeassistant/components/bang_olufsen/__init__.py index f87c5c6732aa..5cbbd468890f 100644 --- a/homeassistant/components/bang_olufsen/__init__.py +++ b/homeassistant/components/bang_olufsen/__init__.py @@ -76,23 +76,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: BeoConfigEntry) -> None: # Create device now as BeoWebsocket needs a device for # debug logging, firing events etc. device_registry = dr.async_get(hass) - device = device_registry.async_get_or_create( + device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.unique_id)}, - model=entry.data[CONF_MODEL], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.unique_id)}, model=entry.data[CONF_MODEL] + ), ) # Create devices for paired Beoremote One remotes for remote in await get_remotes(client): - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, f"{remote.serial_number}_{entry.unique_id}")}, - name=f"{BeoModel.BEOREMOTE_ONE}-{remote.serial_number}-{entry.unique_id}", - model=BeoModel.BEOREMOTE_ONE, - serial_number=remote.serial_number, - sw_version=remote.app_version, - manufacturer=MANUFACTURER, - via_device_id=device.id, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, f"{remote.serial_number}_{entry.unique_id}")}, + name=f"{BeoModel.BEOREMOTE_ONE}-{remote.serial_number}-{entry.unique_id}", + model=BeoModel.BEOREMOTE_ONE, + serial_number=remote.serial_number, + sw_version=remote.app_version, + manufacturer=MANUFACTURER, + via_device_id=device.id, + ), ) websocket = BeoWebsocket(hass, entry, client) diff --git a/homeassistant/components/bond/__init__.py b/homeassistant/components/bond/__init__.py index ebe3aa185959..5fb7ae9af5f8 100644 --- a/homeassistant/components/bond/__init__.py +++ b/homeassistant/components/bond/__init__.py @@ -89,16 +89,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: BondConfigEntry) -> None assert hub.bond_id is not None hub_name = hub.name or hub.bond_id device_registry = dr.async_get(hass) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry_id, - identifiers={(DOMAIN, hub.bond_id)}, - manufacturer=BRIDGE_MAKE, - name=hub_name, - model=hub.target, - sw_version=hub.fw_ver, - hw_version=hub.mcu_ver, - suggested_area=hub.location, - configuration_url=f"http://{host}", + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, hub.bond_id)}, + manufacturer=BRIDGE_MAKE, + name=hub_name, + model=hub.target, + sw_version=hub.fw_ver, + hw_version=hub.mcu_ver, + suggested_area=hub.location, + configuration_url=f"http://{host}", + ), ) _async_remove_old_device_identifiers(config_entry_id, device_registry, hub) diff --git a/homeassistant/components/bosch_alarm/__init__.py b/homeassistant/components/bosch_alarm/__init__.py index ee39d73082e2..8465059771f2 100644 --- a/homeassistant/components/bosch_alarm/__init__.py +++ b/homeassistant/components/bosch_alarm/__init__.py @@ -62,14 +62,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: BoschAlarmConfigEntry) - mac = entry.data.get(CONF_MAC) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(CONNECTION_NETWORK_MAC, mac)} if mac else set(), - identifiers={(DOMAIN, entry.unique_id or entry.entry_id)}, - name=f"Bosch {panel.model.name}", - manufacturer="Bosch Security Systems", - model=panel.model.name, - sw_version=panel.firmware_version, + device_info=dr.DeviceInfo( + connections={(CONNECTION_NETWORK_MAC, mac)} if mac else set(), + identifiers={(DOMAIN, entry.unique_id or entry.entry_id)}, + name=f"Bosch {panel.model.name}", + manufacturer="Bosch Security Systems", + model=panel.model.name, + sw_version=panel.firmware_version, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/bosch_shc/__init__.py b/homeassistant/components/bosch_shc/__init__.py index e9a9ca284369..234bfd5f701f 100644 --- a/homeassistant/components/bosch_shc/__init__.py +++ b/homeassistant/components/bosch_shc/__init__.py @@ -64,14 +64,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: BoschConfigEntry) -> Non entry.runtime_data = session 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, shc_info.unique_id)}, - identifiers={(DOMAIN, shc_info.unique_id)}, - manufacturer="Bosch", - name=entry.title, - model="SmartHomeController", - sw_version=shc_info.version, + device_info=dr.DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, shc_info.unique_id)}, + identifiers={(DOMAIN, shc_info.unique_id)}, + manufacturer="Bosch", + name=entry.title, + model="SmartHomeController", + sw_version=shc_info.version, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/bryant_evolution/__init__.py b/homeassistant/components/bryant_evolution/__init__.py index 7f4ea9e95ea3..7e16352377cb 100644 --- a/homeassistant/components/bryant_evolution/__init__.py +++ b/homeassistant/components/bryant_evolution/__init__.py @@ -35,11 +35,13 @@ async def async_setup_entry( # Add a device for the SAM itself. sam_uid = names.sam_device_uid(entry) device_registry = dr.async_get(hass) - sam_device = device_registry.async_get_or_create( + sam_device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, sam_uid)}, - manufacturer="Bryant", - name="System Access Module", + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, sam_uid)}, + manufacturer="Bryant", + name="System Access Module", + ), ) # Add a device for each system. @@ -52,12 +54,14 @@ async def async_setup_entry( entry.data[CONF_SYSTEM_ZONE], ) continue - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, names.system_device_uid(sam_uid, sys_id))}, - via_device_id=sam_device.id, - manufacturer="Bryant", - name=f"System {sys_id}", + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, names.system_device_uid(sam_uid, sys_id))}, + via_device_id=sam_device.id, + manufacturer="Bryant", + name=f"System {sys_id}", + ), ) # Create a client for every zone. diff --git a/homeassistant/components/bsblan/__init__.py b/homeassistant/components/bsblan/__init__.py index 3577fe1a3c1a..400c3be55e51 100644 --- a/homeassistant/components/bsblan/__init__.py +++ b/homeassistant/components/bsblan/__init__.py @@ -281,16 +281,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: BSBLanConfigEntry) -> No device_registry = dr.async_get(hass) port = entry.data.get(CONF_PORT, DEFAULT_PORT) main_device_info = get_bsblan_device_info(device, info, entry.data[CONF_HOST], port) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers=main_device_info.identifiers, - connections=main_device_info.connections, - name=main_device_info.name, - manufacturer=main_device_info.manufacturer, - model=main_device_info.model, - model_id=main_device_info.model_id, - sw_version=main_device_info.sw_version, - configuration_url=main_device_info.configuration_url, + device_info=dr.DeviceInfo( + identifiers=main_device_info.identifiers, + connections=main_device_info.connections, + name=main_device_info.name, + manufacturer=main_device_info.manufacturer, + model=main_device_info.model, + model_id=main_device_info.model_id, + sw_version=main_device_info.sw_version, + configuration_url=main_device_info.configuration_url, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/bthome/__init__.py b/homeassistant/components/bthome/__init__.py index b6282e811a3e..f6ca47cb45a4 100644 --- a/homeassistant/components/bthome/__init__.py +++ b/homeassistant/components/bthome/__init__.py @@ -116,15 +116,17 @@ def process_service_info( address = service_info.device.address for device_key, event in update.events.items(): sensor_device_info = update.devices[device_key.device_id] - device = device_registry.async_get_or_create( + device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(CONNECTION_BLUETOOTH, address)}, - identifiers={(BLUETOOTH_DOMAIN, address)}, - manufacturer=sensor_device_info.manufacturer, - model=sensor_device_info.model, - name=sensor_device_info.name, - sw_version=sensor_device_info.sw_version, - hw_version=sensor_device_info.hw_version, + device_info=dr.DeviceInfo( + connections={(CONNECTION_BLUETOOTH, address)}, + identifiers={(BLUETOOTH_DOMAIN, address)}, + manufacturer=sensor_device_info.manufacturer, + model=sensor_device_info.model, + name=sensor_device_info.name, + sw_version=sensor_device_info.sw_version, + hw_version=sensor_device_info.hw_version, + ), ) # event_class may be postfixed with a number, ie 'button_2' # but if there is only one button then it will be 'button' diff --git a/homeassistant/components/comelit/coordinator.py b/homeassistant/components/comelit/coordinator.py index 517b2b51c689..fa92a5426cb7 100644 --- a/homeassistant/components/comelit/coordinator.py +++ b/homeassistant/components/comelit/coordinator.py @@ -70,14 +70,16 @@ class ComelitBaseCoordinator(DataUpdateCoordinator[T]): update_interval=timedelta(seconds=SCAN_INTERVAL), ) device_registry = dr.async_get(self.hass) - device_registry.async_get_or_create( - configuration_url=self.api.base_url, + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.entry_id)}, - model=device, - name=f"{device} ({self._host})", - manufacturer="Comelit", - hw_version=self._hw_version, + device_info=dr.DeviceInfo( + configuration_url=self.api.base_url, + identifiers={(DOMAIN, entry.entry_id)}, + model=device, + name=f"{device} ({self._host})", + manufacturer="Comelit", + hw_version=self._hw_version, + ), ) def platform_device_info( diff --git a/homeassistant/components/control4/__init__.py b/homeassistant/components/control4/__init__.py index 97fefdf4e99c..bd25b0bb8ec8 100644 --- a/homeassistant/components/control4/__init__.py +++ b/homeassistant/components/control4/__init__.py @@ -103,14 +103,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: Control4ConfigEntry) -> director_model = model.upper() 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, controller_unique_id)}, - connections={(dr.CONNECTION_NETWORK_MAC, mac_address)}, - manufacturer="Control4", - name=controller_unique_id, - model=director_model, - sw_version=director_sw_version, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, controller_unique_id)}, + connections={(dr.CONNECTION_NETWORK_MAC, mac_address)}, + manufacturer="Control4", + name=controller_unique_id, + model=director_model, + sw_version=director_sw_version, + ), ) # Store all items found on controller for platforms to use diff --git a/homeassistant/components/deconz/hub/hub.py b/homeassistant/components/deconz/hub/hub.py index c304060f6047..33c0e677be4f 100644 --- a/homeassistant/components/deconz/hub/hub.py +++ b/homeassistant/components/deconz/hub/hub.py @@ -172,15 +172,17 @@ class DeconzHub: configuration_url = f"http://{self.config.host}:{self.config.port}" if self.config_entry.source == SOURCE_HASSIO: configuration_url = HASSIO_CONFIGURATION_URL - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - configuration_url=configuration_url, - entry_type=dr.DeviceEntryType.SERVICE, - identifiers={(DOMAIN, self.api.config.bridge_id)}, - manufacturer="dresden elektronik", - model=self.api.config.model_id, - name=self.api.config.name, - sw_version=self.api.config.software_version, + device_info=dr.DeviceInfo( + configuration_url=configuration_url, + entry_type=dr.DeviceEntryType.SERVICE, + identifiers={(DOMAIN, self.api.config.bridge_id)}, + manufacturer="dresden elektronik", + model=self.api.config.model_id, + name=self.api.config.name, + sw_version=self.api.config.software_version, + ), ) @staticmethod diff --git a/homeassistant/components/directv/__init__.py b/homeassistant/components/directv/__init__.py index 72bfcc707496..88de2be4c78f 100644 --- a/homeassistant/components/directv/__init__.py +++ b/homeassistant/components/directv/__init__.py @@ -33,19 +33,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: DirecTVConfigEntry) -> N # Register the receiver device so client entities can link to it via_device_id. 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, dtv.device.info.receiver_id)}, - manufacturer=dtv.device.info.brand, - name=next( - ( - str.title(location.name) - for location in dtv.device.locations - if not location.client + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, dtv.device.info.receiver_id)}, + manufacturer=dtv.device.info.brand, + name=next( + ( + str.title(location.name) + for location in dtv.device.locations + if not location.client + ), + None, ), - None, + sw_version=dtv.device.info.version, ), - sw_version=dtv.device.info.version, ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/dsmr/sensor.py b/homeassistant/components/dsmr/sensor.py index 000a74bd0253..57b176f31799 100644 --- a/homeassistant/components/dsmr/sensor.py +++ b/homeassistant/components/dsmr/sensor.py @@ -674,9 +674,11 @@ def rename_old_gas_to_mbus( entity.entity_id, ) continue - new_device = dev_reg.async_get_or_create( + new_device = dev_reg.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, mbus_device_id)}, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, mbus_device_id)} + ), ) ent_reg.async_update_entity( entity.entity_id, diff --git a/homeassistant/components/duco/__init__.py b/homeassistant/components/duco/__init__.py index f43995c674ab..c62de7842132 100644 --- a/homeassistant/components/duco/__init__.py +++ b/homeassistant/components/duco/__init__.py @@ -44,10 +44,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: DucoConfigEntry) -> None if TYPE_CHECKING: assert mac is not None 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, f"{mac}_{BOX_NODE_ID}")}, - connections={(dr.CONNECTION_NETWORK_MAC, mac)}, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, f"{mac}_{BOX_NODE_ID}")}, + connections={(dr.CONNECTION_NETWORK_MAC, mac)}, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/egauge/__init__.py b/homeassistant/components/egauge/__init__.py index c8ea6638814b..5a6558c4011c 100644 --- a/homeassistant/components/egauge/__init__.py +++ b/homeassistant/components/egauge/__init__.py @@ -21,13 +21,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: EgaugeConfigEntry) -> No # Set up main 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, coordinator.serial_number)}, - name=coordinator.hostname, - manufacturer=MANUFACTURER, - model=MODEL, - serial_number=coordinator.serial_number, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, coordinator.serial_number)}, + name=coordinator.hostname, + manufacturer=MANUFACTURER, + model=MODEL, + serial_number=coordinator.serial_number, + ), ) # Setup sensor platform diff --git a/homeassistant/components/enphase_envoy/__init__.py b/homeassistant/components/enphase_envoy/__init__.py index a450e8635ed4..b15fb2954afc 100644 --- a/homeassistant/components/enphase_envoy/__init__.py +++ b/homeassistant/components/enphase_envoy/__init__.py @@ -46,15 +46,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> N device_registry = dr.async_get(hass) if TYPE_CHECKING: assert envoy.serial_number - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, envoy.serial_number)}, - manufacturer="Enphase", - name=coordinator.name, - model=envoy.envoy_model, - sw_version=str(envoy.firmware), - hw_version=envoy.part_number, - serial_number=envoy.serial_number, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, envoy.serial_number)}, + manufacturer="Enphase", + name=coordinator.name, + model=envoy.envoy_model, + sw_version=str(envoy.firmware), + hw_version=envoy.part_number, + serial_number=envoy.serial_number, + ), ) envoy_data = coordinator.envoy.data @@ -62,30 +64,34 @@ async def async_setup_entry(hass: HomeAssistant, entry: EnphaseConfigEntry) -> N # register the ACB aggregate device before the individual batteries reference # it as via_device, so they nest under it in the device hierarchy if envoy_data and envoy_data.acb_inventory: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, f"{envoy.serial_number}_acb")}, - manufacturer="Enphase", - model="ACB", - name=f"ACB {envoy.serial_number}", - via_device_id=dr.async_get_device_id_by_identifier( - hass, (DOMAIN, envoy.serial_number), config_entry_id=entry.entry_id + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, f"{envoy.serial_number}_acb")}, + manufacturer="Enphase", + model="ACB", + name=f"ACB {envoy.serial_number}", + via_device_id=dr.async_get_device_id_by_identifier( + hass, (DOMAIN, envoy.serial_number), config_entry_id=entry.entry_id + ), ), ) # register the Enpower device before the dry contact relays reference it as # via_device, so they nest under it in the device hierarchy if envoy_data and (enpower := envoy_data.enpower): - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, enpower.serial_number)}, - manufacturer="Enphase", - model="Enpower", - name=f"Enpower {enpower.serial_number}", - sw_version=str(enpower.firmware_version), - serial_number=enpower.serial_number, - via_device_id=dr.async_get_device_id_by_identifier( - hass, (DOMAIN, envoy.serial_number), config_entry_id=entry.entry_id + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, enpower.serial_number)}, + manufacturer="Enphase", + model="Enpower", + name=f"Enpower {enpower.serial_number}", + sw_version=str(enpower.firmware_version), + serial_number=enpower.serial_number, + via_device_id=dr.async_get_device_id_by_identifier( + hass, (DOMAIN, envoy.serial_number), config_entry_id=entry.entry_id + ), ), ) diff --git a/homeassistant/components/enphase_envoy/coordinator.py b/homeassistant/components/enphase_envoy/coordinator.py index 5121150a3fb6..75c3b5c132e2 100644 --- a/homeassistant/components/enphase_envoy/coordinator.py +++ b/homeassistant/components/enphase_envoy/coordinator.py @@ -314,15 +314,17 @@ class EnphaseUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): ) return - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=self.config_entry.entry_id, - identifiers={ - ( - DOMAIN, - self.envoy_serial_number, - ) - }, - connections={connection}, + device_info=dr.DeviceInfo( + identifiers={ + ( + DOMAIN, + self.envoy_serial_number, + ) + }, + connections={connection}, + ), ) _LOGGER.debug("added connection: %s to %s", connection, self.name) diff --git a/homeassistant/components/esphome/manager.py b/homeassistant/components/esphome/manager.py index 977dbde82e3c..b087cbd23455 100644 --- a/homeassistant/components/esphome/manager.py +++ b/homeassistant/components/esphome/manager.py @@ -1339,15 +1339,17 @@ def _async_setup_device_registry( suggested_area = device_info.suggested_area # Create/update main device - device_entry = device_registry.async_get_or_create( + device_entry = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - configuration_url=configuration_url, - connections={(dr.CONNECTION_NETWORK_MAC, device_info.mac_address)}, - name=entry_data.friendly_name or entry_data.name, - manufacturer=manufacturer, - model=model, - sw_version=sw_version, - suggested_area=suggested_area, + device_info=dr.DeviceInfo( + configuration_url=configuration_url, + connections={(dr.CONNECTION_NETWORK_MAC, device_info.mac_address)}, + name=entry_data.friendly_name or entry_data.name, + manufacturer=manufacturer, + model=model, + sw_version=sw_version, + suggested_area=suggested_area, + ), ) # Handle sub devices @@ -1363,14 +1365,18 @@ def _async_setup_device_registry( if sub_device.area_id is not None and sub_device.area_id in areas_by_id: sub_device_suggested_area = areas_by_id[sub_device.area_id].name - sub_device_entry = device_registry.async_get_or_create( + sub_device_entry = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, f"{device_info.mac_address}_{sub_device.device_id}")}, - name=sub_device.name or device_entry.name, - manufacturer=manufacturer, - model=model, - sw_version=sw_version, - suggested_area=sub_device_suggested_area, + device_info=dr.DeviceInfo( + identifiers={ + (DOMAIN, f"{device_info.mac_address}_{sub_device.device_id}") + }, + name=sub_device.name or device_entry.name, + manufacturer=manufacturer, + model=model, + sw_version=sw_version, + suggested_area=sub_device_suggested_area, + ), ) # Update the sub device to set via_device_id diff --git a/homeassistant/components/eurotronic_cometblue/__init__.py b/homeassistant/components/eurotronic_cometblue/__init__.py index b101928300be..f9149f52cad4 100644 --- a/homeassistant/components/eurotronic_cometblue/__init__.py +++ b/homeassistant/components/eurotronic_cometblue/__init__.py @@ -72,14 +72,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: CometBlueConfigEntry) -> ) from ex 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, address)}, - connections={(dr.CONNECTION_BLUETOOTH, address)}, - name=f"{ble_device_info['model']} {address}", - manufacturer=ble_device_info["manufacturer"], - model=ble_device_info["model"], - sw_version=ble_device_info["version"], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, address)}, + connections={(dr.CONNECTION_BLUETOOTH, address)}, + name=f"{ble_device_info['model']} {address}", + manufacturer=ble_device_info["manufacturer"], + model=ble_device_info["model"], + sw_version=ble_device_info["version"], + ), ) coordinator = CometBlueDataUpdateCoordinator(