Use DeviceInfo on components with via_device (H) (#58211)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
c00a5fad8f
commit
58c5b5058c
11 changed files with 108 additions and 97 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
from aiopvapi.resources.shade import ATTR_TYPE
|
||||
|
||||
from homeassistant.const import ATTR_MODEL, ATTR_SW_VERSION
|
||||
import homeassistant.helpers.device_registry as dr
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import (
|
||||
|
@ -63,21 +65,21 @@ class ShadeEntity(HDEntity):
|
|||
self._shade = shade
|
||||
|
||||
@property
|
||||
def device_info(self):
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
|
||||
device_info = {
|
||||
"identifiers": {(DOMAIN, self._shade.id)},
|
||||
"name": self._shade_name,
|
||||
"suggested_area": self._room_name,
|
||||
"manufacturer": MANUFACTURER,
|
||||
"model": str(self._shade.raw_data[ATTR_TYPE]),
|
||||
"via_device": (DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER]),
|
||||
}
|
||||
device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, self._shade.id)},
|
||||
name=self._shade_name,
|
||||
suggested_area=self._room_name,
|
||||
manufacturer=MANUFACTURER,
|
||||
model=str(self._shade.raw_data[ATTR_TYPE]),
|
||||
via_device=(DOMAIN, self._device_info[DEVICE_SERIAL_NUMBER]),
|
||||
)
|
||||
|
||||
for shade in self._shade.shade_types:
|
||||
if shade.shade_type == device_info["model"]:
|
||||
device_info["model"] = shade.description
|
||||
if shade.shade_type == device_info[ATTR_MODEL]:
|
||||
device_info[ATTR_MODEL] = shade.description
|
||||
break
|
||||
|
||||
if FIRMWARE not in self._shade.raw_data:
|
||||
|
@ -86,6 +88,6 @@ class ShadeEntity(HDEntity):
|
|||
firmware = self._shade.raw_data[FIRMWARE]
|
||||
sw_version = f"{firmware[FIRMWARE_REVISION]}.{firmware[FIRMWARE_SUB_REVISION]}.{firmware[FIRMWARE_BUILD]}"
|
||||
|
||||
device_info["sw_version"] = sw_version
|
||||
device_info[ATTR_SW_VERSION] = sw_version
|
||||
|
||||
return device_info
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue