Use DeviceInfo on components with suggested_area (#58225)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
63646a19cc
commit
513c90123e
4 changed files with 35 additions and 41 deletions
|
@ -38,21 +38,21 @@ class HDEntity(CoordinatorEntity):
|
|||
return self._unique_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
firmware = self._device_info[DEVICE_FIRMWARE]
|
||||
sw_version = f"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}"
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER])},
|
||||
"connections": {
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER])},
|
||||
connections={
|
||||
(dr.CONNECTION_NETWORK_MAC, self._device_info[DEVICE_MAC_ADDRESS])
|
||||
},
|
||||
"name": self._device_info[DEVICE_NAME],
|
||||
"suggested_area": self._room_name,
|
||||
"model": self._device_info[DEVICE_MODEL],
|
||||
"sw_version": sw_version,
|
||||
"manufacturer": MANUFACTURER,
|
||||
}
|
||||
name=self._device_info[DEVICE_NAME],
|
||||
suggested_area=self._room_name,
|
||||
model=self._device_info[DEVICE_MODEL],
|
||||
sw_version=sw_version,
|
||||
manufacturer=MANUFACTURER,
|
||||
)
|
||||
|
||||
|
||||
class ShadeEntity(HDEntity):
|
||||
|
|
|
@ -24,6 +24,7 @@ from homeassistant.components.climate.const import (
|
|||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import event as event_helper
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
|
@ -284,12 +285,12 @@ class NuHeatThermostat(CoordinatorEntity, ClimateEntity):
|
|||
self.async_write_ha_state()
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._thermostat.serial_number)},
|
||||
"name": self._thermostat.room,
|
||||
"model": "nVent Signature",
|
||||
"manufacturer": MANUFACTURER,
|
||||
"suggested_area": self._thermostat.room,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._thermostat.serial_number)},
|
||||
name=self._thermostat.room,
|
||||
model="nVent Signature",
|
||||
manufacturer=MANUFACTURER,
|
||||
suggested_area=self._thermostat.room,
|
||||
)
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
"""Base Entity for Roku."""
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.const import (
|
||||
ATTR_IDENTIFIERS,
|
||||
ATTR_MANUFACTURER,
|
||||
ATTR_MODEL,
|
||||
ATTR_NAME,
|
||||
ATTR_SW_VERSION,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
|
@ -33,11 +26,11 @@ class RokuEntity(CoordinatorEntity):
|
|||
if self._device_id is None:
|
||||
return None
|
||||
|
||||
return {
|
||||
ATTR_IDENTIFIERS: {(DOMAIN, self._device_id)},
|
||||
ATTR_NAME: self.coordinator.data.info.name,
|
||||
ATTR_MANUFACTURER: self.coordinator.data.info.brand,
|
||||
ATTR_MODEL: self.coordinator.data.info.model_name,
|
||||
ATTR_SW_VERSION: self.coordinator.data.info.version,
|
||||
"suggested_area": self.coordinator.data.info.device_location,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_id)},
|
||||
name=self.coordinator.data.info.name,
|
||||
manufacturer=self.coordinator.data.info.brand,
|
||||
model=self.coordinator.data.info.model_name,
|
||||
sw_version=self.coordinator.data.info.version,
|
||||
suggested_area=self.coordinator.data.info.device_location,
|
||||
)
|
||||
|
|
|
@ -63,15 +63,15 @@ class TadoZoneEntity(Entity):
|
|||
self.zone_id = zone_id
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, self._device_zone_id)},
|
||||
"name": self.zone_name,
|
||||
"manufacturer": DEFAULT_NAME,
|
||||
"model": TADO_ZONE,
|
||||
"suggested_area": self.zone_name,
|
||||
}
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, self._device_zone_id)},
|
||||
name=self.zone_name,
|
||||
manufacturer=DEFAULT_NAME,
|
||||
model=TADO_ZONE,
|
||||
suggested_area=self.zone_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def should_poll(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue