Migrate Hunter Douglas Powerview to aiopvapi 2.0.0 (#76998)
This commit is contained in:
parent
d1486d04d9
commit
cfa26ae0ca
4 changed files with 33 additions and 25 deletions
|
@ -19,8 +19,7 @@ from aiopvapi.resources.shade import (
|
||||||
MAX_POSITION,
|
MAX_POSITION,
|
||||||
MIN_POSITION,
|
MIN_POSITION,
|
||||||
BaseShade,
|
BaseShade,
|
||||||
ShadeTdbu,
|
ShadeTopDownBottomUp,
|
||||||
Silhouette,
|
|
||||||
factory as PvShade,
|
factory as PvShade,
|
||||||
)
|
)
|
||||||
import async_timeout
|
import async_timeout
|
||||||
|
@ -116,17 +115,18 @@ def create_powerview_shade_entity(
|
||||||
name_before_refresh: str,
|
name_before_refresh: str,
|
||||||
) -> Iterable[ShadeEntity]:
|
) -> Iterable[ShadeEntity]:
|
||||||
"""Create a PowerViewShade entity."""
|
"""Create a PowerViewShade entity."""
|
||||||
|
|
||||||
classes: list[BaseShade] = []
|
classes: list[BaseShade] = []
|
||||||
# order here is important as both ShadeTDBU are listed in aiovapi as can_tilt
|
if isinstance(shade, ShadeTopDownBottomUp):
|
||||||
# and both require their own class here to work
|
|
||||||
if isinstance(shade, ShadeTdbu):
|
|
||||||
classes.extend([PowerViewShadeTDBUTop, PowerViewShadeTDBUBottom])
|
classes.extend([PowerViewShadeTDBUTop, PowerViewShadeTDBUBottom])
|
||||||
elif isinstance(shade, Silhouette):
|
elif ( # this will be extended further in next release for more defined control
|
||||||
classes.append(PowerViewShadeSilhouette)
|
shade.capability.capabilities.tiltOnClosed
|
||||||
elif shade.can_tilt:
|
or shade.capability.capabilities.tiltAnywhere
|
||||||
|
):
|
||||||
classes.append(PowerViewShadeWithTilt)
|
classes.append(PowerViewShadeWithTilt)
|
||||||
else:
|
else:
|
||||||
classes.append(PowerViewShade)
|
classes.append(PowerViewShade)
|
||||||
|
_LOGGER.debug("%s (%s) detected as %a", shade.name, shade.capability.type, classes)
|
||||||
return [
|
return [
|
||||||
cls(coordinator, device_info, room_name, shade, name_before_refresh)
|
cls(coordinator, device_info, room_name, shade, name_before_refresh)
|
||||||
for cls in classes
|
for cls in classes
|
||||||
|
@ -392,8 +392,13 @@ class PowerViewShade(PowerViewShadeBase):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PowerViewShadeTDBU(PowerViewShade):
|
class PowerViewShadeDualRailBase(PowerViewShade):
|
||||||
"""Representation of a PowerView shade with top/down bottom/up capabilities."""
|
"""Representation of a shade with top/down bottom/up capabilities.
|
||||||
|
|
||||||
|
Base methods shared between the two shades created
|
||||||
|
Child Classes: PowerViewShadeTDBUBottom / PowerViewShadeTDBUTop
|
||||||
|
API Class: ShadeTopDownBottomUp
|
||||||
|
"""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def transition_steps(self) -> int:
|
def transition_steps(self) -> int:
|
||||||
|
@ -403,8 +408,13 @@ class PowerViewShadeTDBU(PowerViewShade):
|
||||||
) + hd_position_to_hass(self.positions.secondary, MAX_POSITION)
|
) + hd_position_to_hass(self.positions.secondary, MAX_POSITION)
|
||||||
|
|
||||||
|
|
||||||
class PowerViewShadeTDBUBottom(PowerViewShadeTDBU):
|
class PowerViewShadeTDBUBottom(PowerViewShadeDualRailBase):
|
||||||
"""Representation of a top down bottom up powerview shade."""
|
"""Representation of the bottom PowerViewShadeDualRailBase shade.
|
||||||
|
|
||||||
|
These shades have top/down bottom up functionality and two entiites.
|
||||||
|
Sibling Class: PowerViewShadeTDBUTop
|
||||||
|
API Class: ShadeTopDownBottomUp
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -440,8 +450,13 @@ class PowerViewShadeTDBUBottom(PowerViewShadeTDBU):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class PowerViewShadeTDBUTop(PowerViewShadeTDBU):
|
class PowerViewShadeTDBUTop(PowerViewShadeDualRailBase):
|
||||||
"""Representation of a top down bottom up powerview shade."""
|
"""Representation of the top PowerViewShadeDualRailBase shade.
|
||||||
|
|
||||||
|
These shades have top/down bottom up functionality and two entiites.
|
||||||
|
Sibling Class: PowerViewShadeTDBUBottom
|
||||||
|
API Class: ShadeTopDownBottomUp
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -516,8 +531,6 @@ class PowerViewShadeTDBUTop(PowerViewShadeTDBU):
|
||||||
class PowerViewShadeWithTilt(PowerViewShade):
|
class PowerViewShadeWithTilt(PowerViewShade):
|
||||||
"""Representation of a PowerView shade with tilt capabilities."""
|
"""Representation of a PowerView shade with tilt capabilities."""
|
||||||
|
|
||||||
_max_tilt = MAX_POSITION
|
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: PowerviewShadeUpdateCoordinator,
|
coordinator: PowerviewShadeUpdateCoordinator,
|
||||||
|
@ -535,6 +548,7 @@ class PowerViewShadeWithTilt(PowerViewShade):
|
||||||
)
|
)
|
||||||
if self._device_info.model != LEGACY_DEVICE_MODEL:
|
if self._device_info.model != LEGACY_DEVICE_MODEL:
|
||||||
self._attr_supported_features |= CoverEntityFeature.STOP_TILT
|
self._attr_supported_features |= CoverEntityFeature.STOP_TILT
|
||||||
|
self._max_tilt = self._shade.shade_limits.tilt_max
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_tilt_position(self) -> int:
|
def current_cover_tilt_position(self) -> int:
|
||||||
|
@ -628,9 +642,3 @@ class PowerViewShadeWithTilt(PowerViewShade):
|
||||||
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
|
||||||
"""Stop the cover tilting."""
|
"""Stop the cover tilting."""
|
||||||
await self.async_stop_cover()
|
await self.async_stop_cover()
|
||||||
|
|
||||||
|
|
||||||
class PowerViewShadeSilhouette(PowerViewShadeWithTilt):
|
|
||||||
"""Representation of a Silhouette PowerView shade."""
|
|
||||||
|
|
||||||
_max_tilt = 32767
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"domain": "hunterdouglas_powerview",
|
"domain": "hunterdouglas_powerview",
|
||||||
"name": "Hunter Douglas PowerView",
|
"name": "Hunter Douglas PowerView",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/hunterdouglas_powerview",
|
"documentation": "https://www.home-assistant.io/integrations/hunterdouglas_powerview",
|
||||||
"requirements": ["aiopvapi==1.6.19"],
|
"requirements": ["aiopvapi==2.0.0"],
|
||||||
"codeowners": ["@bdraco", "@kingy444", "@trullock"],
|
"codeowners": ["@bdraco", "@kingy444", "@trullock"],
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"homekit": {
|
"homekit": {
|
||||||
|
|
|
@ -223,7 +223,7 @@ aioopenexchangerates==0.4.0
|
||||||
aiopulse==0.4.3
|
aiopulse==0.4.3
|
||||||
|
|
||||||
# homeassistant.components.hunterdouglas_powerview
|
# homeassistant.components.hunterdouglas_powerview
|
||||||
aiopvapi==1.6.19
|
aiopvapi==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.pvpc_hourly_pricing
|
# homeassistant.components.pvpc_hourly_pricing
|
||||||
aiopvpc==3.0.0
|
aiopvpc==3.0.0
|
||||||
|
|
|
@ -198,7 +198,7 @@ aioopenexchangerates==0.4.0
|
||||||
aiopulse==0.4.3
|
aiopulse==0.4.3
|
||||||
|
|
||||||
# homeassistant.components.hunterdouglas_powerview
|
# homeassistant.components.hunterdouglas_powerview
|
||||||
aiopvapi==1.6.19
|
aiopvapi==2.0.0
|
||||||
|
|
||||||
# homeassistant.components.pvpc_hourly_pricing
|
# homeassistant.components.pvpc_hourly_pricing
|
||||||
aiopvpc==3.0.0
|
aiopvpc==3.0.0
|
||||||
|
|
Loading…
Add table
Reference in a new issue