diff --git a/homeassistant/components/bsblan/__init__.py b/homeassistant/components/bsblan/__init__.py index d688c54824e4..3577fe1a3c1a 100644 --- a/homeassistant/components/bsblan/__init__.py +++ b/homeassistant/components/bsblan/__init__.py @@ -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) diff --git a/homeassistant/components/bsblan/entity.py b/homeassistant/components/bsblan/entity.py index 1f138c385be7..419d9e07ebe2 100644 --- a/homeassistant/components/bsblan/entity.py +++ b/homeassistant/components/bsblan/entity.py @@ -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, ) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index 7c055d426371..82c8d5da2529 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -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( diff --git a/homeassistant/components/lutron_caseta/button.py b/homeassistant/components/lutron_caseta/button.py index 781152315fb9..c2895ee04097 100644 --- a/homeassistant/components/lutron_caseta/button.py +++ b/homeassistant/components/lutron_caseta/button.py @@ -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( diff --git a/homeassistant/components/lutron_caseta/switch.py b/homeassistant/components/lutron_caseta/switch.py index c110c95ad3a5..390ff1f707a1 100644 --- a/homeassistant/components/lutron_caseta/switch.py +++ b/homeassistant/components/lutron_caseta/switch.py @@ -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 diff --git a/homeassistant/components/ouman_eh_800/coordinator.py b/homeassistant/components/ouman_eh_800/coordinator.py index b3f92d7797e7..dd81b69245cd 100644 --- a/homeassistant/components/ouman_eh_800/coordinator.py +++ b/homeassistant/components/ouman_eh_800/coordinator.py @@ -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, diff --git a/homeassistant/components/renault/renault_hub.py b/homeassistant/components/renault/renault_hub.py index 6235d7c6fcf1..ede59cd44ae7 100644 --- a/homeassistant/components/renault/renault_hub.py +++ b/homeassistant/components/renault/renault_hub.py @@ -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 diff --git a/homeassistant/components/shelly/update.py b/homeassistant/components/shelly/update.py index 17f9ed475dc3..bccb047aa3d0 100644 --- a/homeassistant/components/shelly/update.py +++ b/homeassistant/components/shelly/update.py @@ -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 diff --git a/homeassistant/components/stiebel_eltron/diagnostics.py b/homeassistant/components/stiebel_eltron/diagnostics.py index 5267286d830c..047e41992070 100644 --- a/homeassistant/components/stiebel_eltron/diagnostics.py +++ b/homeassistant/components/stiebel_eltron/diagnostics.py @@ -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(),