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 m-p (#187566)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user