Overkiz/address cover feedback (#65043)
This commit is contained in:
parent
759b01bb40
commit
74a304cac7
3 changed files with 24 additions and 35 deletions
|
@ -7,11 +7,11 @@ from pyoverkiz.enums import OverkizCommand, OverkizState
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
DEVICE_CLASS_AWNING,
|
|
||||||
SUPPORT_CLOSE,
|
SUPPORT_CLOSE,
|
||||||
SUPPORT_OPEN,
|
SUPPORT_OPEN,
|
||||||
SUPPORT_SET_POSITION,
|
SUPPORT_SET_POSITION,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
|
CoverDeviceClass,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
||||||
|
@ -20,7 +20,7 @@ from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
||||||
class Awning(OverkizGenericCover):
|
class Awning(OverkizGenericCover):
|
||||||
"""Representation of an Overkiz awning."""
|
"""Representation of an Overkiz awning."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_AWNING
|
_attr_device_class = CoverDeviceClass.AWNING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def supported_features(self) -> int:
|
def supported_features(self) -> int:
|
||||||
|
@ -56,9 +56,8 @@ class Awning(OverkizGenericCover):
|
||||||
|
|
||||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
position = kwargs.get(ATTR_POSITION, 0)
|
|
||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
OverkizCommand.SET_DEPLOYMENT, position
|
OverkizCommand.SET_DEPLOYMENT, kwargs[ATTR_POSITION]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
|
|
|
@ -64,7 +64,7 @@ class OverkizGenericCover(OverkizEntity, CoverEntity):
|
||||||
if command := self.executor.select_command(*COMMANDS_SET_TILT_POSITION):
|
if command := self.executor.select_command(*COMMANDS_SET_TILT_POSITION):
|
||||||
await self.executor.async_execute_command(
|
await self.executor.async_execute_command(
|
||||||
command,
|
command,
|
||||||
100 - kwargs.get(ATTR_TILT_POSITION, 0),
|
100 - kwargs[ATTR_TILT_POSITION],
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
"""Support for Overkiz Vertical Covers."""
|
"""Support for Overkiz Vertical Covers."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Union, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
from pyoverkiz.enums import OverkizCommand, OverkizState, UIClass, UIWidget
|
from pyoverkiz.enums import OverkizCommand, OverkizState, UIClass, UIWidget
|
||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
DEVICE_CLASS_AWNING,
|
|
||||||
DEVICE_CLASS_BLIND,
|
|
||||||
DEVICE_CLASS_CURTAIN,
|
|
||||||
DEVICE_CLASS_GARAGE,
|
|
||||||
DEVICE_CLASS_GATE,
|
|
||||||
DEVICE_CLASS_SHUTTER,
|
|
||||||
DEVICE_CLASS_WINDOW,
|
|
||||||
SUPPORT_CLOSE,
|
SUPPORT_CLOSE,
|
||||||
SUPPORT_OPEN,
|
SUPPORT_OPEN,
|
||||||
SUPPORT_SET_POSITION,
|
SUPPORT_SET_POSITION,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
|
CoverDeviceClass,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
from .generic_cover import COMMANDS_STOP, OverkizGenericCover
|
||||||
|
@ -26,16 +20,16 @@ COMMANDS_OPEN = [OverkizCommand.OPEN, OverkizCommand.UP, OverkizCommand.CYCLE]
|
||||||
COMMANDS_CLOSE = [OverkizCommand.CLOSE, OverkizCommand.DOWN, OverkizCommand.CYCLE]
|
COMMANDS_CLOSE = [OverkizCommand.CLOSE, OverkizCommand.DOWN, OverkizCommand.CYCLE]
|
||||||
|
|
||||||
OVERKIZ_DEVICE_TO_DEVICE_CLASS = {
|
OVERKIZ_DEVICE_TO_DEVICE_CLASS = {
|
||||||
UIClass.CURTAIN: DEVICE_CLASS_CURTAIN,
|
UIClass.CURTAIN: CoverDeviceClass.CURTAIN,
|
||||||
UIClass.EXTERIOR_SCREEN: DEVICE_CLASS_BLIND,
|
UIClass.EXTERIOR_SCREEN: CoverDeviceClass.BLIND,
|
||||||
UIClass.EXTERIOR_VENETIAN_BLIND: DEVICE_CLASS_BLIND,
|
UIClass.EXTERIOR_VENETIAN_BLIND: CoverDeviceClass.BLIND,
|
||||||
UIClass.GARAGE_DOOR: DEVICE_CLASS_GARAGE,
|
UIClass.GARAGE_DOOR: CoverDeviceClass.GARAGE,
|
||||||
UIClass.GATE: DEVICE_CLASS_GATE,
|
UIClass.GATE: CoverDeviceClass.GATE,
|
||||||
UIWidget.MY_FOX_SECURITY_CAMERA: DEVICE_CLASS_SHUTTER,
|
UIWidget.MY_FOX_SECURITY_CAMERA: CoverDeviceClass.SHUTTER,
|
||||||
UIClass.PERGOLA: DEVICE_CLASS_AWNING,
|
UIClass.PERGOLA: CoverDeviceClass.AWNING,
|
||||||
UIClass.ROLLER_SHUTTER: DEVICE_CLASS_SHUTTER,
|
UIClass.ROLLER_SHUTTER: CoverDeviceClass.SHUTTER,
|
||||||
UIClass.SWINGING_SHUTTER: DEVICE_CLASS_SHUTTER,
|
UIClass.SWINGING_SHUTTER: CoverDeviceClass.SHUTTER,
|
||||||
UIClass.WINDOW: DEVICE_CLASS_WINDOW,
|
UIClass.WINDOW: CoverDeviceClass.WINDOW,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +63,7 @@ class VerticalCover(OverkizGenericCover):
|
||||||
(
|
(
|
||||||
OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.widget)
|
OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.widget)
|
||||||
or OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.ui_class)
|
or OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.device.ui_class)
|
||||||
or DEVICE_CLASS_BLIND
|
or CoverDeviceClass.BLIND
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -80,24 +74,20 @@ class VerticalCover(OverkizGenericCover):
|
||||||
|
|
||||||
None is unknown, 0 is closed, 100 is fully open.
|
None is unknown, 0 is closed, 100 is fully open.
|
||||||
"""
|
"""
|
||||||
position = cast(
|
position = self.executor.select_state(
|
||||||
Union[int, None],
|
OverkizState.CORE_CLOSURE,
|
||||||
self.executor.select_state(
|
OverkizState.CORE_CLOSURE_OR_ROCKER_POSITION,
|
||||||
OverkizState.CORE_CLOSURE,
|
OverkizState.CORE_PEDESTRIAN_POSITION,
|
||||||
OverkizState.CORE_CLOSURE_OR_ROCKER_POSITION,
|
|
||||||
OverkizState.CORE_PEDESTRIAN_POSITION,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Uno devices can have a position not in 0 to 100 range when unknown
|
if position is None:
|
||||||
if position is None or position < 0 or position > 100:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return 100 - position
|
return 100 - cast(int, position)
|
||||||
|
|
||||||
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
async def async_set_cover_position(self, **kwargs: Any) -> None:
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
position = 100 - kwargs.get(ATTR_POSITION, 0)
|
position = 100 - kwargs[ATTR_POSITION]
|
||||||
await self.executor.async_execute_command(OverkizCommand.SET_CLOSURE, position)
|
await self.executor.async_execute_command(OverkizCommand.SET_CLOSURE, position)
|
||||||
|
|
||||||
async def async_open_cover(self, **kwargs: Any) -> None:
|
async def async_open_cover(self, **kwargs: Any) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue