Add support for topdown shades to hunterdouglas_powerview (#62788)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
3399be2dad
commit
45e4dd379b
11 changed files with 602 additions and 261 deletions
|
@ -1,6 +1,8 @@
|
|||
"""The nexia integration base entity."""
|
||||
"""The powerview integration base entity."""
|
||||
|
||||
from aiopvapi.resources.shade import ATTR_TYPE
|
||||
from typing import Any
|
||||
|
||||
from aiopvapi.resources.shade import ATTR_TYPE, BaseShade
|
||||
|
||||
from homeassistant.const import ATTR_MODEL, ATTR_SW_VERSION
|
||||
import homeassistant.helpers.device_registry as dr
|
||||
|
@ -20,22 +22,30 @@ from .const import (
|
|||
FIRMWARE_SUB_REVISION,
|
||||
MANUFACTURER,
|
||||
)
|
||||
from .coordinator import PowerviewShadeUpdateCoordinator
|
||||
from .shade_data import PowerviewShadeData, PowerviewShadePositions
|
||||
|
||||
|
||||
class HDEntity(CoordinatorEntity):
|
||||
class HDEntity(CoordinatorEntity[PowerviewShadeUpdateCoordinator]):
|
||||
"""Base class for hunter douglas entities."""
|
||||
|
||||
def __init__(self, coordinator, device_info, room_name, unique_id):
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: PowerviewShadeUpdateCoordinator,
|
||||
device_info: dict[str, Any],
|
||||
room_name: str,
|
||||
unique_id: str,
|
||||
) -> None:
|
||||
"""Initialize the entity."""
|
||||
super().__init__(coordinator)
|
||||
self._room_name = room_name
|
||||
self._unique_id = unique_id
|
||||
self._attr_unique_id = unique_id
|
||||
self._device_info = device_info
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return the unique id."""
|
||||
return self._unique_id
|
||||
def data(self) -> PowerviewShadeData:
|
||||
"""Return the PowerviewShadeData."""
|
||||
return self.coordinator.data
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
|
@ -58,12 +68,24 @@ class HDEntity(CoordinatorEntity):
|
|||
class ShadeEntity(HDEntity):
|
||||
"""Base class for hunter douglas shade entities."""
|
||||
|
||||
def __init__(self, coordinator, device_info, room_name, shade, shade_name):
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: PowerviewShadeUpdateCoordinator,
|
||||
device_info: dict[str, Any],
|
||||
room_name: str,
|
||||
shade: BaseShade,
|
||||
shade_name: str,
|
||||
) -> None:
|
||||
"""Initialize the shade."""
|
||||
super().__init__(coordinator, device_info, room_name, shade.id)
|
||||
self._shade_name = shade_name
|
||||
self._shade = shade
|
||||
|
||||
@property
|
||||
def positions(self) -> PowerviewShadePositions:
|
||||
"""Return the PowerviewShadeData."""
|
||||
return self.data.get_shade_positions(self._shade.id)
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device_info of the device."""
|
||||
|
@ -78,7 +100,7 @@ class ShadeEntity(HDEntity):
|
|||
)
|
||||
|
||||
for shade in self._shade.shade_types:
|
||||
if shade.shade_type == device_info[ATTR_MODEL]:
|
||||
if str(shade.shade_type) == device_info[ATTR_MODEL]:
|
||||
device_info[ATTR_MODEL] = shade.description
|
||||
break
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue