mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Pass a DeviceInfo to async_get_or_create_device in integrations f-i (#187549)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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] = []
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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():
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user