1 """Support for Overkiz Vertical Covers."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 from pyoverkiz.enums
import (
21 from ..coordinator
import OverkizDataUpdateCoordinator
22 from .generic_cover
import (
29 COMMANDS_OPEN = [OverkizCommand.OPEN, OverkizCommand.UP, OverkizCommand.CYCLE]
30 COMMANDS_CLOSE = [OverkizCommand.CLOSE, OverkizCommand.DOWN, OverkizCommand.CYCLE]
32 OVERKIZ_DEVICE_TO_DEVICE_CLASS = {
33 UIClass.CURTAIN: CoverDeviceClass.CURTAIN,
34 UIClass.EXTERIOR_SCREEN: CoverDeviceClass.BLIND,
35 UIClass.EXTERIOR_VENETIAN_BLIND: CoverDeviceClass.BLIND,
36 UIClass.GARAGE_DOOR: CoverDeviceClass.GARAGE,
37 UIClass.GATE: CoverDeviceClass.GATE,
38 UIWidget.MY_FOX_SECURITY_CAMERA: CoverDeviceClass.SHUTTER,
39 UIClass.PERGOLA: CoverDeviceClass.AWNING,
40 UIClass.ROLLER_SHUTTER: CoverDeviceClass.SHUTTER,
41 UIClass.SWINGING_SHUTTER: CoverDeviceClass.SHUTTER,
42 UIClass.WINDOW: CoverDeviceClass.WINDOW,
47 """Representation of an Overkiz vertical cover."""
50 self, device_url: str, coordinator: OverkizDataUpdateCoordinator
52 """Initialize vertical cover."""
53 super().
__init__(device_url, coordinator)
55 OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.
devicedevice.widget)
56 or OVERKIZ_DEVICE_TO_DEVICE_CLASS.get(self.
devicedevice.ui_class)
57 or CoverDeviceClass.BLIND
62 """Flag supported features."""
63 supported_features = super().supported_features
65 if self.
executorexecutor.has_command(OverkizCommand.SET_CLOSURE):
66 supported_features |= CoverEntityFeature.SET_POSITION
68 if self.
executorexecutor.has_command(*COMMANDS_OPEN):
69 supported_features |= CoverEntityFeature.OPEN
71 if self.
executorexecutor.has_command(*COMMANDS_STOP):
72 supported_features |= CoverEntityFeature.STOP
74 if self.
executorexecutor.has_command(*COMMANDS_CLOSE):
75 supported_features |= CoverEntityFeature.CLOSE
77 return supported_features
81 """Return current position of cover.
83 None is unknown, 0 is closed, 100 is fully open.
85 position = self.
executorexecutor.select_state(
86 OverkizState.CORE_CLOSURE,
87 OverkizState.CORE_CLOSURE_OR_ROCKER_POSITION,
88 OverkizState.CORE_PEDESTRIAN_POSITION,
94 return 100 - cast(int, position)
97 """Move the cover to a specific position."""
98 position = 100 - kwargs[ATTR_POSITION]
99 await self.
executorexecutor.async_execute_command(OverkizCommand.SET_CLOSURE, position)
102 """Open the cover."""
103 if command := self.
executorexecutor.select_command(*COMMANDS_OPEN):
104 await self.
executorexecutor.async_execute_command(command)
107 """Close the cover."""
108 if command := self.
executorexecutor.select_command(*COMMANDS_CLOSE):
109 await self.
executorexecutor.async_execute_command(command)
113 """Return if the cover is opening or not."""
114 if self.
is_runningis_running(COMMANDS_OPEN + COMMANDS_OPEN_TILT):
118 is_moving = self.
devicedevice.states.get(OverkizState.CORE_MOVING)
119 current_closure = self.
devicedevice.states.get(OverkizState.CORE_CLOSURE)
120 target_closure = self.
devicedevice.states.get(OverkizState.CORE_TARGET_CLOSURE)
122 if not is_moving
or not current_closure
or not target_closure:
125 return cast(int, current_closure.value) > cast(int, target_closure.value)
129 """Return if the cover is closing or not."""
130 if self.
is_runningis_running(COMMANDS_CLOSE + COMMANDS_CLOSE_TILT):
134 is_moving = self.
devicedevice.states.get(OverkizState.CORE_MOVING)
135 current_closure = self.
devicedevice.states.get(OverkizState.CORE_CLOSURE)
136 target_closure = self.
devicedevice.states.get(OverkizState.CORE_TARGET_CLOSURE)
138 if not is_moving
or not current_closure
or not target_closure:
141 return cast(int, current_closure.value) < cast(int, target_closure.value)
145 """Representation of an Overkiz Low Speed cover."""
150 coordinator: OverkizDataUpdateCoordinator,
152 """Initialize the device."""
153 super().
__init__(device_url, coordinator)
158 """Move the cover to a specific position."""
162 """Open the cover."""
166 """Close the cover."""
170 """Move the cover to a specific position with a low speed."""
171 position = 100 - kwargs.get(ATTR_POSITION, 0)
173 await self.
executorexecutor.async_execute_command(
174 OverkizCommand.SET_CLOSURE_AND_LINEAR_SPEED,
176 OverkizCommandParam.LOWSPEED,
bool is_running(self, list[OverkizCommand] commands)
None __init__(self, str device_url, OverkizDataUpdateCoordinator coordinator)
None async_open_cover(self, **Any kwargs)
None async_set_cover_position(self, **Any kwargs)
None async_set_cover_position_low_speed(self, **Any kwargs)
None async_close_cover(self, **Any kwargs)
CoverEntityFeature supported_features(self)
None async_open_cover(self, **Any kwargs)
bool|None is_closing(self)
None async_set_cover_position(self, **Any kwargs)
None __init__(self, str device_url, OverkizDataUpdateCoordinator coordinator)
None async_close_cover(self, **Any kwargs)
bool|None is_opening(self)