diff --git a/homeassistant/components/screenlogic/__init__.py b/homeassistant/components/screenlogic/__init__.py index 2178cf7ec2cceb..894a8a5e527693 100644 --- a/homeassistant/components/screenlogic/__init__.py +++ b/homeassistant/components/screenlogic/__init__.py @@ -19,6 +19,7 @@ from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr from homeassistant.helpers.debounce import Debouncer +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, @@ -215,7 +216,7 @@ def gateway_name(self): return self.gateway.name @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return device information for the controller.""" controller_type = self.config_data["controller_type"] hardware_type = self.config_data["hardware_type"] @@ -225,12 +226,12 @@ def device_info(self): ] except KeyError: equipment_model = f"Unknown Model C:{controller_type} H:{hardware_type}" - return { - "connections": {(dr.CONNECTION_NETWORK_MAC, self.mac)}, - "name": self.gateway_name, - "manufacturer": "Pentair", - "model": equipment_model, - } + return DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, self.mac)}, + manufacturer="Pentair", + model=equipment_model, + name=self.gateway_name, + ) class ScreenLogicCircuitEntity(ScreenlogicEntity): diff --git a/homeassistant/components/sharkiq/vacuum.py b/homeassistant/components/sharkiq/vacuum.py index 4ecdf217abc0ce..3851dab7303eaf 100644 --- a/homeassistant/components/sharkiq/vacuum.py +++ b/homeassistant/components/sharkiq/vacuum.py @@ -123,15 +123,15 @@ def model(self) -> str: @property def device_info(self) -> DeviceInfo: """Device info dictionary.""" - return { - "identifiers": {(DOMAIN, self.serial_number)}, - "name": self.name, - "manufacturer": SHARK, - "model": self.model, - "sw_version": self.sharkiq.get_property_value( + return DeviceInfo( + identifiers={(DOMAIN, self.serial_number)}, + manufacturer=SHARK, + model=self.model, + name=self.name, + sw_version=self.sharkiq.get_property_value( Properties.ROBOT_FIRMWARE_VERSION ), - } + ) @property def supported_features(self) -> int: diff --git a/homeassistant/components/shelly/entity.py b/homeassistant/components/shelly/entity.py index 0a610545180f36..e33a2d87317443 100644 --- a/homeassistant/components/shelly/entity.py +++ b/homeassistant/components/shelly/entity.py @@ -282,6 +282,9 @@ def __init__(self, wrapper: BlockDeviceWrapper, block: Block) -> None: self.wrapper = wrapper self.block = block self._name = get_block_entity_name(wrapper.device, block) + self._attr_device_info = DeviceInfo( + connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} + ) @property def name(self) -> str: @@ -293,13 +296,6 @@ def should_poll(self) -> bool: """If device should be polled.""" return False - @property - def device_info(self) -> DeviceInfo: - """Device info.""" - return { - "connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)} - } - @property def available(self) -> bool: """Available.""" @@ -348,9 +344,9 @@ def __init__(self, wrapper: RpcDeviceWrapper, key: str) -> None: self.wrapper = wrapper self.key = key self._attr_should_poll = False - self._attr_device_info = { - "connections": {(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} - } + self._attr_device_info = DeviceInfo( + connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} + ) self._attr_unique_id = f"{wrapper.mac}-{key}" self._attr_name = get_rpc_entity_name(wrapper.device, key) @@ -494,19 +490,15 @@ def __init__( self.description = description self._name = get_block_entity_name(wrapper.device, None, self.description.name) self._last_value = None + self._attr_device_info = DeviceInfo( + connections={(device_registry.CONNECTION_NETWORK_MAC, wrapper.mac)} + ) @property def name(self) -> str: """Name of sensor.""" return self._name - @property - def device_info(self) -> DeviceInfo: - """Device info.""" - return { - "connections": {(device_registry.CONNECTION_NETWORK_MAC, self.wrapper.mac)} - } - @property def entity_registry_enabled_default(self) -> bool: """Return if it should be enabled by default.""" diff --git a/homeassistant/components/sma/sensor.py b/homeassistant/components/sma/sensor.py index 922ec9f92121ce..853edee823cf47 100644 --- a/homeassistant/components/sma/sensor.py +++ b/homeassistant/components/sma/sensor.py @@ -200,18 +200,18 @@ def unique_id(self) -> str: ) @property - def device_info(self) -> DeviceInfo: + def device_info(self) -> DeviceInfo | None: """Return the device information.""" if not self._device_info: return None - return { - "identifiers": {(DOMAIN, self._config_entry_unique_id)}, - "name": self._device_info["name"], - "manufacturer": self._device_info["manufacturer"], - "model": self._device_info["type"], - "sw_version": self._device_info["sw_version"], - } + return DeviceInfo( + identifiers={(DOMAIN, self._config_entry_unique_id)}, + manufacturer=self._device_info["manufacturer"], + model=self._device_info["type"], + name=self._device_info["name"], + sw_version=self._device_info["sw_version"], + ) @property def entity_registry_enabled_default(self) -> bool: diff --git a/homeassistant/components/smappee/binary_sensor.py b/homeassistant/components/smappee/binary_sensor.py index 4cc5cca9a23aac..7e46a1021e515b 100644 --- a/homeassistant/components/smappee/binary_sensor.py +++ b/homeassistant/components/smappee/binary_sensor.py @@ -3,6 +3,7 @@ DEVICE_CLASS_PRESENCE, BinarySensorEntity, ) +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN @@ -71,15 +72,15 @@ def unique_id( ) @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device info for this binary sensor.""" - return { - "identifiers": {(DOMAIN, self._service_location.device_serial_number)}, - "name": self._service_location.service_location_name, - "manufacturer": "Smappee", - "model": self._service_location.device_model, - "sw_version": self._service_location.firmware_version, - } + return DeviceInfo( + identifiers={(DOMAIN, self._service_location.device_serial_number)}, + manufacturer="Smappee", + model=self._service_location.device_model, + name=self._service_location.service_location_name, + sw_version=self._service_location.firmware_version, + ) async def async_update(self): """Get the latest data from Smappee and update the state.""" @@ -154,15 +155,15 @@ def unique_id( ) @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device info for this binary sensor.""" - return { - "identifiers": {(DOMAIN, self._service_location.device_serial_number)}, - "name": self._service_location.service_location_name, - "manufacturer": "Smappee", - "model": self._service_location.device_model, - "sw_version": self._service_location.firmware_version, - } + return DeviceInfo( + identifiers={(DOMAIN, self._service_location.device_serial_number)}, + manufacturer="Smappee", + model=self._service_location.device_model, + name=self._service_location.service_location_name, + sw_version=self._service_location.firmware_version, + ) async def async_update(self): """Get the latest data from Smappee and update the state.""" diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index af66b788a41314..276248fd6ae759 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -18,6 +18,7 @@ ENERGY_WATT_HOUR, POWER_WATT, ) +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN @@ -372,15 +373,15 @@ def unique_id(self): ) @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device info for this sensor.""" - return { - "identifiers": {(DOMAIN, self._service_location.device_serial_number)}, - "name": self._service_location.service_location_name, - "manufacturer": "Smappee", - "model": self._service_location.device_model, - "sw_version": self._service_location.firmware_version, - } + return DeviceInfo( + identifiers={(DOMAIN, self._service_location.device_serial_number)}, + manufacturer="Smappee", + model=self._service_location.device_model, + name=self._service_location.service_location_name, + sw_version=self._service_location.firmware_version, + ) async def async_update(self): """Get the latest data from Smappee and update the state.""" diff --git a/homeassistant/components/smappee/switch.py b/homeassistant/components/smappee/switch.py index ded898f9f104e8..3376523598b792 100644 --- a/homeassistant/components/smappee/switch.py +++ b/homeassistant/components/smappee/switch.py @@ -1,5 +1,6 @@ """Support for interacting with Smappee Comport Plugs, Switches and Output Modules.""" from homeassistant.components.switch import SwitchEntity +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN @@ -148,15 +149,15 @@ def unique_id( ) @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device info for this switch.""" - return { - "identifiers": {(DOMAIN, self._service_location.device_serial_number)}, - "name": self._service_location.service_location_name, - "manufacturer": "Smappee", - "model": self._service_location.device_model, - "sw_version": self._service_location.firmware_version, - } + return DeviceInfo( + identifiers={(DOMAIN, self._service_location.device_serial_number)}, + name=self._service_location.service_location_name, + manufacturer="Smappee", + model=self._service_location.device_model, + sw_version=self._service_location.firmware_version, + ) async def async_update(self): """Get the latest data from Smappee and update the state.""" diff --git a/homeassistant/components/smartthings/__init__.py b/homeassistant/components/smartthings/__init__.py index eb3aa9cb0f0ef0..96eb70fa23afce 100644 --- a/homeassistant/components/smartthings/__init__.py +++ b/homeassistant/components/smartthings/__init__.py @@ -21,7 +21,7 @@ async_dispatcher_connect, async_dispatcher_send, ) -from homeassistant.helpers.entity import Entity +from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType @@ -409,6 +409,12 @@ def __init__(self, device: DeviceEntity) -> None: """Initialize the instance.""" self._device = device self._dispatcher_remove = None + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, device.device_id)}, + manufacturer="Unavailable", + model=device.device_type_name, + name=device.label, + ) async def async_added_to_hass(self): """Device added to hass.""" @@ -427,16 +433,6 @@ async def async_will_remove_from_hass(self) -> None: if self._dispatcher_remove: self._dispatcher_remove() - @property - def device_info(self): - """Get attributes about the device.""" - return { - "identifiers": {(DOMAIN, self._device.device_id)}, - "name": self._device.label, - "model": self._device.device_type_name, - "manufacturer": "Unavailable", - } - @property def name(self) -> str: """Return the name of the device.""" diff --git a/homeassistant/components/smarttub/entity.py b/homeassistant/components/smarttub/entity.py index 49d5e94d76e55d..bcaaeb7db86842 100644 --- a/homeassistant/components/smarttub/entity.py +++ b/homeassistant/components/smarttub/entity.py @@ -26,21 +26,17 @@ def __init__( super().__init__(coordinator) self.spa = spa self._entity_name = entity_name + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, spa.id)}, + manufacturer=spa.brand, + model=spa.model, + ) @property def unique_id(self) -> str: """Return a unique id for the entity.""" return f"{self.spa.id}-{self._entity_name}" - @property - def device_info(self) -> DeviceInfo: - """Return device info.""" - return { - "identifiers": {(DOMAIN, self.spa.id)}, - "manufacturer": self.spa.brand, - "model": self.spa.model, - } - @property def name(self) -> str: """Return the name of the entity.""" diff --git a/homeassistant/components/sms/sensor.py b/homeassistant/components/sms/sensor.py index d405c8176566cf..f5152ac74625da 100644 --- a/homeassistant/components/sms/sensor.py +++ b/homeassistant/components/sms/sensor.py @@ -5,6 +5,7 @@ from homeassistant.components.sensor import SensorEntity, SensorEntityDescription from homeassistant.const import DEVICE_CLASS_SIGNAL_STRENGTH, SIGNAL_STRENGTH_DECIBELS +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN, SMS_GATEWAY @@ -39,10 +40,10 @@ class GSMSignalSensor(SensorEntity): def __init__(self, hass, gateway, imei, description): """Initialize the GSM Signal sensor.""" - self._attr_device_info = { - "identifiers": {(DOMAIN, str(imei))}, - "name": "SMS Gateway", - } + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, str(imei))}, + name="SMS Gateway", + ) self._attr_unique_id = str(imei) self._hass = hass self._gateway = gateway diff --git a/homeassistant/components/solarlog/sensor.py b/homeassistant/components/solarlog/sensor.py index 5918c397a7b4dd..d54845f8027f69 100644 --- a/homeassistant/components/solarlog/sensor.py +++ b/homeassistant/components/solarlog/sensor.py @@ -1,7 +1,7 @@ """Platform for solarlog sensors.""" from homeassistant.components.sensor import SensorEntity from homeassistant.helpers import update_coordinator -from homeassistant.helpers.entity import StateType +from homeassistant.helpers.entity import DeviceInfo, StateType from . import SolarlogData from .const import DOMAIN, SENSOR_TYPES, SolarLogSensorEntityDescription @@ -30,11 +30,11 @@ def __init__( self.entity_description = description self._attr_name = f"{coordinator.name} {description.name}" self._attr_unique_id = f"{coordinator.unique_id}_{description.key}" - self._attr_device_info = { - "identifiers": {(DOMAIN, coordinator.unique_id)}, - "name": coordinator.name, - "manufacturer": "Solar-Log", - } + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, coordinator.unique_id)}, + manufacturer="Solar-Log", + name=coordinator.name, + ) @property def native_value(self) -> StateType: diff --git a/homeassistant/components/soma/__init__.py b/homeassistant/components/soma/__init__.py index 77ecd3af96bfee..532e6204ad90c6 100644 --- a/homeassistant/components/soma/__init__.py +++ b/homeassistant/components/soma/__init__.py @@ -8,7 +8,7 @@ from homeassistant.const import CONF_HOST, CONF_PORT from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.entity import Entity +from homeassistant.helpers.entity import DeviceInfo, Entity from .const import API, DOMAIN, HOST, PORT @@ -89,13 +89,13 @@ def name(self): return self.device["name"] @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return device specific attributes. Implemented by platform classes. """ - return { - "identifiers": {(DOMAIN, self.unique_id)}, - "name": self.name, - "manufacturer": "Wazombi Labs", - } + return DeviceInfo( + identifiers={(DOMAIN, self.unique_id)}, + manufacturer="Wazombi Labs", + name=self.name, + ) diff --git a/homeassistant/components/somfy_mylink/cover.py b/homeassistant/components/somfy_mylink/cover.py index 2725e2da9c7a60..b4eb847a5e03db 100644 --- a/homeassistant/components/somfy_mylink/cover.py +++ b/homeassistant/components/somfy_mylink/cover.py @@ -8,6 +8,7 @@ CoverEntity, ) from homeassistant.const import STATE_CLOSED, STATE_OPEN +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.restore_state import RestoreEntity from .const import ( @@ -115,13 +116,13 @@ def is_closed(self) -> bool: return self._closed @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self._target_id)}, - "name": self._name, - "manufacturer": MANUFACTURER, - } + return DeviceInfo( + identifiers={(DOMAIN, self._target_id)}, + manufacturer=MANUFACTURER, + name=self._name, + ) async def async_close_cover(self, **kwargs): """Close the cover.""" diff --git a/homeassistant/components/songpal/media_player.py b/homeassistant/components/songpal/media_player.py index 1746d5ece0dd41..b13ca99cd5b0f2 100644 --- a/homeassistant/components/songpal/media_player.py +++ b/homeassistant/components/songpal/media_player.py @@ -32,6 +32,7 @@ device_registry as dr, entity_platform, ) +from homeassistant.helpers.entity import DeviceInfo from .const import CONF_ENDPOINT, DOMAIN, SET_SOUND_SETTING @@ -205,16 +206,16 @@ def unique_id(self): return self._sysinfo.macAddr @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device info.""" - return { - "connections": {(dr.CONNECTION_NETWORK_MAC, self._sysinfo.macAddr)}, - "identifiers": {(DOMAIN, self.unique_id)}, - "manufacturer": "Sony Corporation", - "name": self.name, - "sw_version": self._sysinfo.version, - "model": self._model, - } + return DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, self._sysinfo.macAddr)}, + identifiers={(DOMAIN, self.unique_id)}, + manufacturer="Sony Corporation", + model=self._model, + name=self.name, + sw_version=self._sysinfo.version, + ) @property def available(self): diff --git a/homeassistant/components/speedtestdotnet/sensor.py b/homeassistant/components/speedtestdotnet/sensor.py index 06f180a570f170..1c4bdc51f3c352 100644 --- a/homeassistant/components/speedtestdotnet/sensor.py +++ b/homeassistant/components/speedtestdotnet/sensor.py @@ -62,10 +62,10 @@ def __init__( self._state: StateType = None self._attrs = {ATTR_ATTRIBUTION: ATTRIBUTION} self._attr_device_info = DeviceInfo( + configuration_url="https://www.speedtest.net/", + entry_type="service", identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)}, name=DEFAULT_NAME, - entry_type="service", - configuration_url="https://www.speedtest.net/", ) @property diff --git a/homeassistant/components/spider/climate.py b/homeassistant/components/spider/climate.py index 52146518ee3595..9f9a3ebbbaca0a 100644 --- a/homeassistant/components/spider/climate.py +++ b/homeassistant/components/spider/climate.py @@ -8,6 +8,7 @@ SUPPORT_TARGET_TEMPERATURE, ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN @@ -45,14 +46,14 @@ def __init__(self, api, thermostat): self.thermostat = thermostat @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self.thermostat.id)}, - "name": self.thermostat.name, - "manufacturer": self.thermostat.manufacturer, - "model": self.thermostat.model, - } + return DeviceInfo( + identifiers={(DOMAIN, self.thermostat.id)}, + manufacturer=self.thermostat.manufacturer, + model=self.thermostat.model, + name=self.thermostat.name, + ) @property def supported_features(self): diff --git a/homeassistant/components/spider/sensor.py b/homeassistant/components/spider/sensor.py index 8b38fdbe6f689c..1e469b1097089a 100644 --- a/homeassistant/components/spider/sensor.py +++ b/homeassistant/components/spider/sensor.py @@ -42,12 +42,12 @@ def __init__(self, api, power_plug) -> None: @property def device_info(self) -> DeviceInfo: """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self.power_plug.id)}, - "name": self.power_plug.name, - "manufacturer": self.power_plug.manufacturer, - "model": self.power_plug.model, - } + return DeviceInfo( + identifiers={(DOMAIN, self.power_plug.id)}, + manufacturer=self.power_plug.manufacturer, + model=self.power_plug.model, + name=self.power_plug.name, + ) @property def unique_id(self) -> str: @@ -80,16 +80,12 @@ def __init__(self, api, power_plug) -> None: """Initialize the Spider Power Plug.""" self.api = api self.power_plug = power_plug - - @property - def device_info(self) -> DeviceInfo: - """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self.power_plug.id)}, - "name": self.power_plug.name, - "manufacturer": self.power_plug.manufacturer, - "model": self.power_plug.model, - } + self._attr_device_info = DeviceInfo( + identifiers={(DOMAIN, power_plug.id)}, + manufacturer=power_plug.manufacturer, + model=power_plug.model, + name=power_plug.name, + ) @property def unique_id(self) -> str: diff --git a/homeassistant/components/spider/switch.py b/homeassistant/components/spider/switch.py index ceb814b234a37b..4569105b8f4c05 100644 --- a/homeassistant/components/spider/switch.py +++ b/homeassistant/components/spider/switch.py @@ -1,5 +1,6 @@ """Support for Spider switches.""" from homeassistant.components.switch import SwitchEntity +from homeassistant.helpers.entity import DeviceInfo from .const import DOMAIN @@ -24,14 +25,14 @@ def __init__(self, api, power_plug): self.power_plug = power_plug @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self.power_plug.id)}, - "name": self.power_plug.name, - "manufacturer": self.power_plug.manufacturer, - "model": self.power_plug.model, - } + return DeviceInfo( + identifiers={(DOMAIN, self.power_plug.id)}, + manufacturer=self.power_plug.manufacturer, + model=self.power_plug.model, + name=self.power_plug.name, + ) @property def unique_id(self): diff --git a/homeassistant/components/spotify/media_player.py b/homeassistant/components/spotify/media_player.py index 029f7dc9e8b051..4359c20ba5f1ef 100644 --- a/homeassistant/components/spotify/media_player.py +++ b/homeassistant/components/spotify/media_player.py @@ -238,9 +238,7 @@ def __init__( name: str, ) -> None: """Initialize.""" - self._id = user_id self._me = me - self._name = f"Spotify {name}" self._session = session self._spotify = spotify self._scope_ok = set(session.token["scope"].split(" ")).issuperset( @@ -251,7 +249,7 @@ def __init__( self._devices: list[dict] | None = [] self._playlist: dict | None = None - self._attr_name = self._name + self._attr_name = f"Spotify {name}" self._attr_unique_id = user_id @property @@ -263,12 +261,12 @@ def device_info(self) -> DeviceInfo: model = f"Spotify {product}" return DeviceInfo( - identifiers={(DOMAIN, self._id)}, + configuration_url="https://open.spotify.com", + entry_type="service", + identifiers={(DOMAIN, self._attr_unique_id)}, manufacturer="Spotify AB", model=model, - name=self._name, - entry_type="service", - configuration_url="https://open.spotify.com", + name=f"Spotify {self.name}", ) @property diff --git a/homeassistant/components/starline/account.py b/homeassistant/components/starline/account.py index 9033375ce907be..920c9214aeca5c 100644 --- a/homeassistant/components/starline/account.py +++ b/homeassistant/components/starline/account.py @@ -129,13 +129,13 @@ def unload(self): @staticmethod def device_info(device: StarlineDevice) -> DeviceInfo: """Device information for entities.""" - return { - "identifiers": {(DOMAIN, device.device_id)}, - "manufacturer": "StarLine", - "name": device.name, - "sw_version": device.fw_version, - "model": device.typename, - } + return DeviceInfo( + identifiers={(DOMAIN, device.device_id)}, + manufacturer="StarLine", + model=device.typename, + name=device.name, + sw_version=device.fw_version, + ) @staticmethod def gps_attrs(device: StarlineDevice) -> dict[str, Any]: diff --git a/homeassistant/components/stookalert/binary_sensor.py b/homeassistant/components/stookalert/binary_sensor.py index b75790cef8af32..54fac6cc633d04 100644 --- a/homeassistant/components/stookalert/binary_sensor.py +++ b/homeassistant/components/stookalert/binary_sensor.py @@ -79,12 +79,12 @@ def __init__(self, client: stookalert.stookalert, entry: ConfigEntry) -> None: self._attr_name = f"Stookalert {entry.data[CONF_PROVINCE]}" self._attr_unique_id = entry.unique_id self._attr_device_info = DeviceInfo( + entry_type=ENTRY_TYPE_SERVICE, + configuration_url="https://www.rivm.nl/stookalert", identifiers={(DOMAIN, f"{entry.entry_id}")}, - name=entry.data[CONF_PROVINCE], manufacturer="RIVM", model="Stookalert", - entry_type=ENTRY_TYPE_SERVICE, - configuration_url="https://www.rivm.nl/stookalert", + name=entry.data[CONF_PROVINCE], ) def update(self) -> None: diff --git a/homeassistant/components/subaru/entity.py b/homeassistant/components/subaru/entity.py index 559feeea303ca1..2bdb1425b2d64c 100644 --- a/homeassistant/components/subaru/entity.py +++ b/homeassistant/components/subaru/entity.py @@ -1,4 +1,5 @@ """Base class for all Subaru Entities.""" +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DOMAIN, MANUFACTURER, VEHICLE_NAME, VEHICLE_VIN @@ -25,10 +26,10 @@ def unique_id(self) -> str: return f"{self.vin}_{self.entity_type}" @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return the device_info of the device.""" - return { - "identifiers": {(DOMAIN, self.vin)}, - "name": self.car_name, - "manufacturer": MANUFACTURER, - } + return DeviceInfo( + identifiers={(DOMAIN, self.vin)}, + manufacturer=MANUFACTURER, + name=self.car_name, + ) diff --git a/homeassistant/components/switchbot/entity.py b/homeassistant/components/switchbot/entity.py index d6e88174d793bb..688cfea6a86202 100644 --- a/homeassistant/components/switchbot/entity.py +++ b/homeassistant/components/switchbot/entity.py @@ -28,12 +28,12 @@ def __init__( self._idx = idx self._mac = mac self._attr_name = name - self._attr_device_info: DeviceInfo = { - "connections": {(dr.CONNECTION_NETWORK_MAC, self._mac)}, - "name": name, - "model": self.data["modelName"], - "manufacturer": MANUFACTURER, - } + self._attr_device_info = DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, self._mac)}, + manufacturer=MANUFACTURER, + model=self.data["modelName"], + name=name, + ) @property def data(self) -> dict[str, Any]: diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index 8b93e422e2a206..620a742f4e37a2 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -23,6 +23,7 @@ entity_platform, ) from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -92,11 +93,11 @@ def __init__(self, coordinator: SwitcherDataUpdateCoordinator) -> None: # Entity class attributes self._attr_name = coordinator.name self._attr_unique_id = f"{coordinator.device_id}-{coordinator.mac_address}" - self._attr_device_info = { - "connections": { + self._attr_device_info = DeviceInfo( + connections={ (device_registry.CONNECTION_NETWORK_MAC, coordinator.mac_address) } - } + ) @callback def _handle_coordinator_update(self) -> None: diff --git a/homeassistant/components/syncthing/sensor.py b/homeassistant/components/syncthing/sensor.py index e88636b814bb26..192b4c5c39546e 100644 --- a/homeassistant/components/syncthing/sensor.py +++ b/homeassistant/components/syncthing/sensor.py @@ -6,6 +6,7 @@ from homeassistant.core import callback from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers.dispatcher import async_dispatcher_connect +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.event import async_track_time_interval from .const import ( @@ -130,15 +131,15 @@ def should_poll(self): return False @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return device information.""" - return { - "identifiers": {(DOMAIN, self._server_id)}, - "name": f"Syncthing ({self._syncthing.url})", - "manufacturer": "Syncthing Team", - "sw_version": self._version, - "entry_type": "service", - } + return DeviceInfo( + entry_type="service", + identifiers={(DOMAIN, self._server_id)}, + manufacturer="Syncthing Team", + name=f"Syncthing ({self._syncthing.url})", + sw_version=self._version, + ) async def async_update_status(self): """Request folder status and update state.""" diff --git a/homeassistant/components/syncthru/binary_sensor.py b/homeassistant/components/syncthru/binary_sensor.py index 1c402fbf836bcc..edc03bfee6f825 100644 --- a/homeassistant/components/syncthru/binary_sensor.py +++ b/homeassistant/components/syncthru/binary_sensor.py @@ -8,6 +8,7 @@ BinarySensorEntity, ) from homeassistant.const import CONF_NAME +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -50,6 +51,9 @@ def __init__(self, coordinator, name): self.syncthru: SyncThru = coordinator.data self._name = name self._id_suffix = "" + self._attr_device_info = DeviceInfo( + identifiers=device_identifiers(self.syncthru) + ) @property def unique_id(self): @@ -62,11 +66,6 @@ def name(self): """Return the name of the sensor.""" return self._name - @property - def device_info(self): - """Return device information.""" - return {"identifiers": device_identifiers(self.syncthru)} - class SyncThruOnlineSensor(SyncThruBinarySensor): """Implementation of a sensor that checks whether is turned on/online.""" diff --git a/homeassistant/components/syncthru/sensor.py b/homeassistant/components/syncthru/sensor.py index cc832f77f0afb7..f3c699b4d4d8e5 100644 --- a/homeassistant/components/syncthru/sensor.py +++ b/homeassistant/components/syncthru/sensor.py @@ -9,6 +9,7 @@ from homeassistant.config_entries import SOURCE_IMPORT from homeassistant.const import CONF_NAME, CONF_RESOURCE, CONF_URL, PERCENTAGE import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, @@ -106,6 +107,9 @@ def __init__(self, coordinator, name): self._icon = "mdi:printer" self._unit_of_measurement = None self._id_suffix = "" + self._attr_device_info = DeviceInfo( + identifiers=device_identifiers(self.syncthru) + ) @property def unique_id(self): @@ -128,11 +132,6 @@ def native_unit_of_measurement(self): """Return the unit of measuremnt.""" return self._unit_of_measurement - @property - def device_info(self): - """Return device information.""" - return {"identifiers": device_identifiers(self.syncthru)} - class SyncThruMainSensor(SyncThruSensor): """ diff --git a/homeassistant/components/synology_dsm/__init__.py b/homeassistant/components/synology_dsm/__init__.py index a8e35178be4d79..932353356124cc 100644 --- a/homeassistant/components/synology_dsm/__init__.py +++ b/homeassistant/components/synology_dsm/__init__.py @@ -614,12 +614,12 @@ def __init__( def device_info(self) -> DeviceInfo: """Return the device information.""" return DeviceInfo( + configuration_url=self._api.config_url, identifiers={(DOMAIN, self._api.information.serial)}, - name="Synology NAS", manufacturer="Synology", model=self._api.information.model, + name="Synology NAS", sw_version=self._api.information.version_string, - configuration_url=self._api.config_url, ) async def async_added_to_hass(self) -> None: @@ -683,11 +683,11 @@ def available(self) -> bool: def device_info(self) -> DeviceInfo: """Return the device information.""" return DeviceInfo( + configuration_url=self._api.config_url, identifiers={(DOMAIN, f"{self._api.information.serial}_{self._device_id}")}, - name=f"Synology NAS ({self._device_name} - {self._device_type})", manufacturer=self._device_manufacturer, model=self._device_model, + name=f"Synology NAS ({self._device_name} - {self._device_type})", sw_version=self._device_firmware, via_device=(DOMAIN, self._api.information.serial), - configuration_url=self._api.config_url, ) diff --git a/homeassistant/components/system_bridge/__init__.py b/homeassistant/components/system_bridge/__init__.py index d1da463816f416..faea8b8418cdd4 100644 --- a/homeassistant/components/system_bridge/__init__.py +++ b/homeassistant/components/system_bridge/__init__.py @@ -262,10 +262,10 @@ class SystemBridgeDeviceEntity(SystemBridgeEntity): @property def device_info(self) -> DeviceInfo: """Return device information about this System Bridge instance.""" - return { - "connections": {(dr.CONNECTION_NETWORK_MAC, self._mac)}, - "manufacturer": self._manufacturer, - "model": self._model, - "name": self._hostname, - "sw_version": self._version, - } + return DeviceInfo( + connections={(dr.CONNECTION_NETWORK_MAC, self._mac)}, + manufacturer=self._manufacturer, + model=self._model, + name=self._hostname, + sw_version=self._version, + )