Read DeviceInfo fields as attributes instead of by key (#186607)

This commit is contained in:
epenet
2026-10-15 09:57:15 +02:00
committed by GitHub
parent 185ddbb309
commit a53dcbfaf2
9 changed files with 26 additions and 32 deletions
+8 -8
View File
@@ -283,14 +283,14 @@ async def async_setup_entry(hass: HomeAssistant, entry: BSBLanConfigEntry) -> No
main_device_info = get_bsblan_device_info(device, info, entry.data[CONF_HOST], port)
device_registry.async_get_or_create(
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.get("model"),
model_id=main_device_info.get("model_id"),
sw_version=main_device_info.get("sw_version"),
configuration_url=main_device_info.get("configuration_url"),
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)
+6 -6
View File
@@ -59,9 +59,9 @@ class BSBLanCircuitEntity(BSBLanEntity):
(DOMAIN, mac),
config_entry_id=coordinator.config_entry.entry_id,
),
manufacturer=main_info["manufacturer"],
model=main_info.get("model"),
model_id=main_info.get("model_id"),
manufacturer=main_info.manufacturer,
model=main_info.model,
model_id=main_info.model_id,
)
@@ -111,7 +111,7 @@ class BSBLanWaterHeaterDeviceEntity(BSBLanDualCoordinatorEntity):
(DOMAIN, mac),
config_entry_id=fast_coordinator.config_entry.entry_id,
),
manufacturer=main_info["manufacturer"],
model=main_info.get("model"),
model_id=main_info.get("model_id"),
manufacturer=main_info.manufacturer,
model=main_info.model,
model_id=main_info.model_id,
)
+1 -1
View File
@@ -766,7 +766,7 @@ class Thermostat(ClimateEntity):
LOGGER.debug(
"Setting sensors %s to be used on thermostat %s for program %s",
sensor_names,
self.device_info.get("name"),
self.device_info.name,
preset_mode,
)
self.data.ecobee.update_climate_sensors(
@@ -51,7 +51,7 @@ async def async_setup_entry(
# Append the child device name to the end of the parent keypad
# name to create the entity name
full_name = f"{parent_device_info.get('name')} {device_name}"
full_name = f"{parent_device_info.name} {device_name}"
# Set the device_info to the same as the Parent Keypad
# The entities will be nested inside the keypad device
entities.append(
@@ -55,7 +55,7 @@ class LutronCasetaLight(LutronCasetaUpdatableEntity, SwitchEntity):
parent_device_info = parent_keypad["device_info"]
# Append the child device name to the end of the
# parent keypad name to create the entity name
self._attr_name = f"{parent_device_info['name']} {device['device_name']}"
self._attr_name = f"{parent_device_info.name} {device['device_name']}"
# Set the device_info to the same as the Parent Keypad
# The entities will be nested inside the keypad device
self._attr_device_info = parent_device_info
@@ -29,6 +29,7 @@ from homeassistant.exceptions import (
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.typing import UNDEFINED
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .const import DEFAULT_SCAN_INTERVAL_SECONDS, DOMAIN, OumanDevice
@@ -97,7 +98,7 @@ class OumanEh800Coordinator(DataUpdateCoordinator[OumanEh800Data]):
def device_info(self, device: OumanDevice) -> DeviceInfo:
"""Return the device info for a logical device."""
device_info = self._device_info[device]
if device is not OumanDevice.MAIN and "via_device_id" not in device_info:
if device is not OumanDevice.MAIN and device_info.via_device_id is UNDEFINED:
device_info.via_device_id = dr.async_get_device_id_by_identifier(
self.hass,
self._main_device_identifier,
@@ -14,13 +14,6 @@ from renault_api.kamereon.models import KamereonVehiclesLink
from renault_api.renault_account import RenaultAccount
from renault_api.renault_client import RenaultClient
from homeassistant.const import (
ATTR_IDENTIFIERS,
ATTR_MANUFACTURER,
ATTR_MODEL,
ATTR_MODEL_ID,
ATTR_NAME,
)
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
@@ -201,11 +194,11 @@ class RenaultHub:
await vehicle.async_initialise()
device_registry.async_get_or_create(
config_entry_id=config_entry.entry_id,
identifiers=vehicle.device_info[ATTR_IDENTIFIERS],
manufacturer=vehicle.device_info[ATTR_MANUFACTURER],
name=vehicle.device_info[ATTR_NAME],
model=vehicle.device_info[ATTR_MODEL],
model_id=vehicle.device_info[ATTR_MODEL_ID],
identifiers=vehicle.device_info.identifiers,
manufacturer=vehicle.device_info.manufacturer,
name=vehicle.device_info.name,
model=vehicle.device_info.model,
model_id=vehicle.device_info.model_id,
sw_version=None, # cleanup from PR #125399
)
self._vehicles[vehicle_link.vin] = vehicle
+1 -1
View File
@@ -192,7 +192,7 @@ class RpcBluTrvUpdateEntity(ShellyRpcAttributeEntity, UpdateEntity):
super().__init__(coordinator, key, attribute, description)
self._attr_device_info = get_entity_blu_trv_device_info(coordinator, key)
self._blu_trv_name = cast(str, self._attr_device_info["name"])
self._blu_trv_name = cast(str, self._attr_device_info.name)
update_coordinator = coordinator.config_entry.runtime_data.rpc_blu_trv_update
@@ -19,7 +19,7 @@ async def async_get_config_entry_diagnostics(
return {
"entry_data": async_redact_data(entry.data, TO_REDACT),
"model": coordinator.device_info["model"],
"model": coordinator.device_info.model,
"data": {
"current_temp": coordinator.api_client.get_current_temp(),
"target_temp": coordinator.api_client.get_target_temp(),