diff --git a/homeassistant/components/mobile_app/__init__.py b/homeassistant/components/mobile_app/__init__.py index 18574eca0913..0a83e2405f7e 100644 --- a/homeassistant/components/mobile_app/__init__.py +++ b/homeassistant/components/mobile_app/__init__.py @@ -203,13 +203,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> None: 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, registration[ATTR_DEVICE_ID])}, - manufacturer=registration[ATTR_MANUFACTURER], - model=registration[ATTR_MODEL], - name=registration[ATTR_DEVICE_NAME], - sw_version=registration[ATTR_OS_VERSION], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, registration[ATTR_DEVICE_ID])}, + manufacturer=registration[ATTR_MANUFACTURER], + model=registration[ATTR_MODEL], + name=registration[ATTR_DEVICE_NAME], + sw_version=registration[ATTR_OS_VERSION], + ), ) hass.data[DOMAIN][DATA_DEVICES][webhook_id] = device diff --git a/homeassistant/components/mobile_app/webhook.py b/homeassistant/components/mobile_app/webhook.py index d4443124dd28..6c2494a85aba 100644 --- a/homeassistant/components/mobile_app/webhook.py +++ b/homeassistant/components/mobile_app/webhook.py @@ -440,13 +440,15 @@ async def webhook_update_registration( 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, - identifiers={(DOMAIN, config_entry.data[ATTR_DEVICE_ID])}, - manufacturer=new_registration[ATTR_MANUFACTURER], - model=new_registration[ATTR_MODEL], - name=new_registration[ATTR_DEVICE_NAME], - sw_version=new_registration[ATTR_OS_VERSION], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, config_entry.data[ATTR_DEVICE_ID])}, + manufacturer=new_registration[ATTR_MANUFACTURER], + model=new_registration[ATTR_MODEL], + name=new_registration[ATTR_DEVICE_NAME], + sw_version=new_registration[ATTR_OS_VERSION], + ), ) hass.config_entries.async_update_entry(config_entry, data=new_registration) diff --git a/homeassistant/components/motioneye/__init__.py b/homeassistant/components/motioneye/__init__.py index bc042550a6ce..65dceaea01ba 100644 --- a/homeassistant/components/motioneye/__init__.py +++ b/homeassistant/components/motioneye/__init__.py @@ -220,12 +220,14 @@ def _add_camera( ), ) - device = device_registry.async_get_or_create( + device = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={device_identifier}, - manufacturer=MOTIONEYE_MANUFACTURER, - model=MOTIONEYE_MANUFACTURER, - name=camera[KEY_NAME], + device_info=dr.DeviceInfo( + identifiers={device_identifier}, + manufacturer=MOTIONEYE_MANUFACTURER, + model=MOTIONEYE_MANUFACTURER, + name=camera[KEY_NAME], + ), ) if entry.options.get(CONF_WEBHOOK_SET, DEFAULT_WEBHOOK_SET): url = async_generate_motioneye_webhook(hass, entry.data[CONF_WEBHOOK_ID]) diff --git a/homeassistant/components/myuplink/__init__.py b/homeassistant/components/myuplink/__init__.py index c5a951f08015..17cca4ce4bf0 100644 --- a/homeassistant/components/myuplink/__init__.py +++ b/homeassistant/components/myuplink/__init__.py @@ -98,14 +98,16 @@ def create_devices( devices_in_system = [x.id for x in system.devices] for device_id, device in coordinator.data.devices.items(): if device_id in devices_in_system: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=config_entry.entry_id, - identifiers={(DOMAIN, device_id)}, - name=get_system_name(system), - manufacturer=get_manufacturer(device), - model=get_model(device), - sw_version=device.firmwareCurrent, - serial_number=device.product_serial_number, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, device_id)}, + name=get_system_name(system), + manufacturer=get_manufacturer(device), + model=get_model(device), + sw_version=device.firmwareCurrent, + serial_number=device.product_serial_number, + ), ) diff --git a/homeassistant/components/nanoleaf/__init__.py b/homeassistant/components/nanoleaf/__init__.py index 44a8a7a2ed38..09bbccc3362e 100644 --- a/homeassistant/components/nanoleaf/__init__.py +++ b/homeassistant/components/nanoleaf/__init__.py @@ -47,9 +47,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: NanoleafConfigEntry) -> if supports_touch := nanoleaf.model in TOUCH_MODELS: device_registry = dr.async_get(hass) - device_entry = device_registry.async_get_or_create( + device_entry = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, nanoleaf.serial_no)}, + device_info=dr.DeviceInfo(identifiers={(DOMAIN, nanoleaf.serial_no)}), ) async def touch_event_callback(event: TouchEvent) -> None: diff --git a/homeassistant/components/nasweb/__init__.py b/homeassistant/components/nasweb/__init__.py index c6bb2782561d..bb9d0fb8b7bd 100644 --- a/homeassistant/components/nasweb/__init__.py +++ b/homeassistant/components/nasweb/__init__.py @@ -108,12 +108,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: NASwebConfigEntry) -> No ) from error 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, webio_serial)}, - manufacturer=MANUFACTURER, - name=webio_api.get_name(), - configuration_url=NASWEB_CONFIG_URL.format(host=entry.data[CONF_HOST]), + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, webio_serial)}, + manufacturer=MANUFACTURER, + name=webio_api.get_name(), + configuration_url=NASWEB_CONFIG_URL.format(host=entry.data[CONF_HOST]), + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/netatmo/device.py b/homeassistant/components/netatmo/device.py index bde32dd9ee4b..02d0b888ac74 100644 --- a/homeassistant/components/netatmo/device.py +++ b/homeassistant/components/netatmo/device.py @@ -85,13 +85,15 @@ def _register_bridge( manufacturer, model = DEVICE_DESCRIPTION_MAP.get( module.device_type, (MANUFACTURER, module.device_type.value) ) - device_entry = device_registry.async_get_or_create( + device_entry = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, module_id)}, - manufacturer=manufacturer, - model=model, - name=module.name, - via_device_id=via_device_id, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, module_id)}, + manufacturer=manufacturer, + model=model, + name=module.name, + via_device_id=via_device_id, + ), ) parent_device_ids[module_id] = device_entry.id return device_entry.id @@ -133,13 +135,15 @@ def async_register_parent_devices( parent_device_ids: dict[str, str] = {} for home_id, home_name in account.all_home_names.items(): - device_entry = device_registry.async_get_or_create( + device_entry = device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, home_id)}, - manufacturer=MANUFACTURER, - model="Home", - name=home_name, - configuration_url=CONF_URL_CONTROL, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, home_id)}, + manufacturer=MANUFACTURER, + model="Home", + name=home_name, + configuration_url=CONF_URL_CONTROL, + ), ) parent_device_ids[home_id] = device_entry.id diff --git a/homeassistant/components/nexia/__init__.py b/homeassistant/components/nexia/__init__.py index 13f9feb1e64c..94a0c49fdaa7 100644 --- a/homeassistant/components/nexia/__init__.py +++ b/homeassistant/components/nexia/__init__.py @@ -89,16 +89,18 @@ def _preregister_devices( device_registry = dr.async_get(hass) for thermostat_id in nexia_home.get_thermostat_ids(): thermostat = nexia_home.get_thermostat_by_id(thermostat_id) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, thermostat_id)}, # type: ignore[arg-type] # until fix issue #139773 + device_info=dr.DeviceInfo(identifiers={(DOMAIN, thermostat_id)}), # type: ignore[arg-type] # until fix issue #139773 ) for zone_id in thermostat.get_zone_ids(): zone = thermostat.get_zone_by_id(zone_id) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, zone_id)}, # type: ignore[arg-type] # until fix issue #139773 - suggested_area=zone.get_name(), + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, zone_id)}, # type: ignore[arg-type] # until fix issue #139773 + suggested_area=zone.get_name(), + ), ) diff --git a/homeassistant/components/nibe_heatpump/__init__.py b/homeassistant/components/nibe_heatpump/__init__.py index 8b758c30587d..12cf2cbfd582 100644 --- a/homeassistant/components/nibe_heatpump/__init__.py +++ b/homeassistant/components/nibe_heatpump/__init__.py @@ -85,11 +85,13 @@ async def async_setup_entry( entry.runtime_data = coordinator reg = dr.async_get(hass) - device_entry = reg.async_get_or_create( + device_entry = reg.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.unique_id or entry.entry_id)}, - manufacturer="NIBE Energy Systems", - name=heatpump.model.name, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.unique_id or entry.entry_id)}, + manufacturer="NIBE Energy Systems", + name=heatpump.model.name, + ), ) def _on_product_info(product_info: ProductInfo): diff --git a/homeassistant/components/nightscout/__init__.py b/homeassistant/components/nightscout/__init__.py index 621edcf1f776..815864b2145d 100644 --- a/homeassistant/components/nightscout/__init__.py +++ b/homeassistant/components/nightscout/__init__.py @@ -33,13 +33,15 @@ async def async_setup_entry(hass: HomeAssistant, entry: NightscoutConfigEntry) - entry.runtime_data = api 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, server_url)}, - manufacturer="Nightscout Foundation", - name=status.name, - sw_version=status.version, - entry_type=dr.DeviceEntryType.SERVICE, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, server_url)}, + manufacturer="Nightscout Foundation", + name=status.name, + sw_version=status.version, + entry_type=dr.DeviceEntryType.SERVICE, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/nobo_hub/__init__.py b/homeassistant/components/nobo_hub/__init__.py index beeff8ccd7d7..4a6e21622ce3 100644 --- a/homeassistant/components/nobo_hub/__init__.py +++ b/homeassistant/components/nobo_hub/__init__.py @@ -102,16 +102,18 @@ async def async_setup_entry(hass: HomeAssistant, entry: NoboHubConfigEntry) -> N connections: set[tuple[str, str]] = set() if mac := entry.data.get(CONF_MAC): connections.add((CONNECTION_NETWORK_MAC, mac)) - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, hub.hub_serial)}, - connections=connections, - serial_number=hub.hub_serial, - name=hub.hub_info[ATTR_NAME], - manufacturer=NOBO_MANUFACTURER, - model="Nobø Ecohub", - sw_version=hub.hub_info[ATTR_SOFTWARE_VERSION], - hw_version=hub.hub_info[ATTR_HARDWARE_VERSION], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, hub.hub_serial)}, + connections=connections, + serial_number=hub.hub_serial, + name=hub.hub_info[ATTR_NAME], + manufacturer=NOBO_MANUFACTURER, + model="Nobø Ecohub", + sw_version=hub.hub_info[ATTR_SOFTWARE_VERSION], + hw_version=hub.hub_info[ATTR_HARDWARE_VERSION], + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/notion/coordinator.py b/homeassistant/components/notion/coordinator.py index 9f5f90980228..a01398d69a2f 100644 --- a/homeassistant/components/notion/coordinator.py +++ b/homeassistant/components/notion/coordinator.py @@ -42,13 +42,15 @@ def _async_register_new_bridge( bridge_name = str(bridge.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, bridge.hardware_id)}, - manufacturer="Silicon Labs", - model=str(bridge.hardware_revision), - name=bridge_name, - sw_version=bridge.firmware_version.wifi, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, bridge.hardware_id)}, + manufacturer="Silicon Labs", + model=str(bridge.hardware_revision), + name=bridge_name, + sw_version=bridge.firmware_version.wifi, + ), ) diff --git a/homeassistant/components/nuki/__init__.py b/homeassistant/components/nuki/__init__.py index ea4fc50c2917..3a08cc658fa0 100644 --- a/homeassistant/components/nuki/__init__.py +++ b/homeassistant/components/nuki/__init__.py @@ -193,14 +193,16 @@ async def async_setup_entry(hass: HomeAssistant, entry: NukiConfigEntry) -> None # Device registration for the bridge bridge_id = parse_id(info["ids"]["hardwareId"]) dev_reg = dr.async_get(hass) - dev_reg.async_get_or_create( + dev_reg.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, bridge_id)}, - manufacturer="Nuki Home Solutions GmbH", - name=f"Nuki Bridge {bridge_id}", - model="Hardware Bridge", - sw_version=info["versions"]["firmwareVersion"], - serial_number=parse_id(info["ids"]["hardwareId"]), + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, bridge_id)}, + manufacturer="Nuki Home Solutions GmbH", + name=f"Nuki Bridge {bridge_id}", + model="Hardware Bridge", + sw_version=info["versions"]["firmwareVersion"], + serial_number=parse_id(info["ids"]["hardwareId"]), + ), ) try: diff --git a/homeassistant/components/ondilo_ico/coordinator.py b/homeassistant/components/ondilo_ico/coordinator.py index 4040e801b16d..9710e3265445 100644 --- a/homeassistant/components/ondilo_ico/coordinator.py +++ b/homeassistant/components/ondilo_ico/coordinator.py @@ -79,13 +79,15 @@ class OndiloIcoPoolsCoordinator(DataUpdateCoordinator[dict[str, OndiloIcoPoolDat pool_data.measures_coordinator = OndiloIcoMeasuresCoordinator( self.hass, self.config_entry, self.api, pool_id ) - 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, pool_data.ico["serial_number"])}, - manufacturer="Ondilo", - model="ICO", - name=pool_data.pool["name"], - sw_version=pool_data.ico["sw_version"], + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, pool_data.ico["serial_number"])}, + manufacturer="Ondilo", + model="ICO", + name=pool_data.pool["name"], + sw_version=pool_data.ico["sw_version"], + ), ) removed_pools = known_pools - current_pools diff --git a/homeassistant/components/opendisplay/__init__.py b/homeassistant/components/opendisplay/__init__.py index 5ab2f89068f7..142d6655932c 100644 --- a/homeassistant/components/opendisplay/__init__.py +++ b/homeassistant/components/opendisplay/__init__.py @@ -137,21 +137,23 @@ async def async_setup_entry(hass: HomeAssistant, entry: OpenDisplayConfigEntry) if display.screen_diagonal_inches is not None else f"{display.pixel_width}x{display.pixel_height}" ) - dr.async_get(hass).async_get_or_create( + dr.async_get(hass).async_get_or_create_device( config_entry_id=entry.entry_id, - connections={(CONNECTION_BLUETOOTH, address)}, - manufacturer=manufacturer.manufacturer_name, - model=f"{size} {color_scheme}", - sw_version=f"{fw['major']}.{fw['minor']}.{fw['patch']}", - hw_version=( - f"{manufacturer.board_type_name or manufacturer.board_type}" - f" rev. {manufacturer.board_revision}" - ) - if is_flex - else None, - configuration_url="https://opendisplay.org/firmware/config/" - if is_flex - else None, + device_info=dr.DeviceInfo( + connections={(CONNECTION_BLUETOOTH, address)}, + manufacturer=manufacturer.manufacturer_name, + model=f"{size} {color_scheme}", + sw_version=f"{fw['major']}.{fw['minor']}.{fw['patch']}", + hw_version=( + f"{manufacturer.board_type_name or manufacturer.board_type}" + f" rev. {manufacturer.board_revision}" + ) + if is_flex + else None, + configuration_url="https://opendisplay.org/firmware/config/" + if is_flex + else None, + ), ) entry.runtime_data = OpenDisplayRuntimeData( diff --git a/homeassistant/components/openrgb/__init__.py b/homeassistant/components/openrgb/__init__.py index b805bd625428..0d165c3e341f 100644 --- a/homeassistant/components/openrgb/__init__.py +++ b/homeassistant/components/openrgb/__init__.py @@ -122,14 +122,16 @@ def _setup_server_device_registry( device_registry = dr.async_get(hass) # Create the parent OpenRGB SDK server device - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.entry_id)}, - name=entry.data[CONF_NAME], - model="OpenRGB SDK Server", - manufacturer="OpenRGB", - sw_version=coordinator.get_client_protocol_version(), - entry_type=dr.DeviceEntryType.SERVICE, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.entry_id)}, + name=entry.data[CONF_NAME], + model="OpenRGB SDK Server", + manufacturer="OpenRGB", + sw_version=coordinator.get_client_protocol_version(), + entry_type=dr.DeviceEntryType.SERVICE, + ), ) diff --git a/homeassistant/components/opentherm_gw/__init__.py b/homeassistant/components/opentherm_gw/__init__.py index 6470a5c7fd3a..b810968cfb0a 100644 --- a/homeassistant/components/opentherm_gw/__init__.py +++ b/homeassistant/components/opentherm_gw/__init__.py @@ -120,30 +120,38 @@ class OpenThermGatewayHub: "Connected to OpenTherm Gateway %s at %s", self.gw_version, self.device_path ) dev_reg = dr.async_get(self.hass) - gw_dev = dev_reg.async_get_or_create( + gw_dev = dev_reg.async_get_or_create_device( config_entry_id=self.config_entry_id, - identifiers={ - (DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.GATEWAY}") - }, - manufacturer="Schelte Bron", - model="OpenTherm Gateway", - translation_key="gateway_device", - sw_version=self.gw_version, + device_info=dr.DeviceInfo( + identifiers={ + (DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.GATEWAY}") + }, + manufacturer="Schelte Bron", + model="OpenTherm Gateway", + translation_key="gateway_device", + sw_version=self.gw_version, + ), ) if gw_dev.sw_version != self.gw_version: dev_reg.async_update_device(gw_dev.id, sw_version=self.gw_version) - boiler_device = dev_reg.async_get_or_create( + boiler_device = dev_reg.async_get_or_create_device( config_entry_id=self.config_entry_id, - identifiers={(DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.BOILER}")}, - translation_key="boiler_device", + device_info=dr.DeviceInfo( + identifiers={ + (DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.BOILER}") + }, + translation_key="boiler_device", + ), ) - thermostat_device = dev_reg.async_get_or_create( + thermostat_device = dev_reg.async_get_or_create_device( config_entry_id=self.config_entry_id, - identifiers={ - (DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.THERMOSTAT}") - }, - translation_key="thermostat_device", + device_info=dr.DeviceInfo( + identifiers={ + (DOMAIN, f"{self.hub_id}-{OpenThermDeviceIdentifier.THERMOSTAT}") + }, + translation_key="thermostat_device", + ), ) self.hass.bus.async_listen(EVENT_HOMEASSISTANT_STOP, self.cleanup) diff --git a/homeassistant/components/overkiz/__init__.py b/homeassistant/components/overkiz/__init__.py index ae6064d94fbf..e35a993dc2aa 100644 --- a/homeassistant/components/overkiz/__init__.py +++ b/homeassistant/components/overkiz/__init__.py @@ -196,18 +196,20 @@ async def async_setup_entry(hass: HomeAssistant, entry: OverkizDataConfigEntry) registered_gateway_ids = {gateway.id for gateway in setup.gateways} for gateway in setup.gateways: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, gateway.id)}, - model=gateway.type.beautify_name if gateway.type else None, - model_id=str(gateway.type), - manufacturer=client.server_config.manufacturer, - name=gateway.type.beautify_name if gateway.type else gateway.id, - sw_version=gateway.connectivity.protocol_version, - hw_version=f"{gateway.type}:{gateway.sub_type}" - if gateway.type and gateway.sub_type - else None, - configuration_url=client.server_config.configuration_url, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, gateway.id)}, + model=gateway.type.beautify_name if gateway.type else None, + model_id=str(gateway.type), + manufacturer=client.server_config.manufacturer, + name=gateway.type.beautify_name if gateway.type else gateway.id, + sw_version=gateway.connectivity.protocol_version, + hw_version=f"{gateway.type}:{gateway.sub_type}" + if gateway.type and gateway.sub_type + else None, + configuration_url=client.server_config.configuration_url, + ), ) # Some devices reference a gateway that is not part of setup.gateways @@ -216,12 +218,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: OverkizDataConfigEntry) for gateway_id in { device.identifier.gateway_id for device in coordinator.data.values() } - registered_gateway_ids: - device_registry.async_get_or_create( + device_registry.async_get_or_create_device( config_entry_id=entry.entry_id, - identifiers={(DOMAIN, gateway_id)}, - manufacturer=client.server_config.manufacturer, - name=gateway_id, - configuration_url=client.server_config.configuration_url, + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, gateway_id)}, + manufacturer=client.server_config.manufacturer, + name=gateway_id, + configuration_url=client.server_config.configuration_url, + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) diff --git a/homeassistant/components/pglab/discovery.py b/homeassistant/components/pglab/discovery.py index 371c935e0332..55c416ac4fc9 100644 --- a/homeassistant/components/pglab/discovery.py +++ b/homeassistant/components/pglab/discovery.py @@ -222,16 +222,18 @@ class PGLabDiscovery: # Create a new device. 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, - configuration_url=f"http://{pglab_device.ip}/", - connections={(CONNECTION_NETWORK_MAC, pglab_device.mac)}, - identifiers={(DOMAIN, pglab_device.id)}, - manufacturer=pglab_device.manufacturer, - model=pglab_device.type, - name=pglab_device.name, - sw_version=pglab_device.firmware_version, - hw_version=pglab_device.hardware_version, + device_info=dr.DeviceInfo( + configuration_url=f"http://{pglab_device.ip}/", + connections={(CONNECTION_NETWORK_MAC, pglab_device.mac)}, + identifiers={(DOMAIN, pglab_device.id)}, + manufacturer=pglab_device.manufacturer, + model=pglab_device.type, + name=pglab_device.name, + sw_version=pglab_device.firmware_version, + hw_version=pglab_device.hardware_version, + ), ) # Do some checking if previous entities must be updated. diff --git a/homeassistant/components/ping/__init__.py b/homeassistant/components/ping/__init__.py index 76f9813e09e0..7fd4d5658d3f 100644 --- a/homeassistant/components/ping/__init__.py +++ b/homeassistant/components/ping/__init__.py @@ -70,10 +70,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: PingConfigEntry) -> None # Ensure the device exists before forwarding to platforms, so that the # device tracker (which looks up the device on init) is not racing the # binary sensor / sensor platforms that create the device via DeviceInfo. - 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="Ping", + device_info=dr.DeviceInfo( + identifiers={(DOMAIN, entry.entry_id)}, manufacturer="Ping" + ), ) await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)