1 """Base class for Overkiz covers, shutters, awnings, etc."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 from pyoverkiz.enums
import OverkizCommand, OverkizCommandParam, OverkizState
15 from ..entity
import OverkizEntity
17 ATTR_OBSTRUCTION_DETECTED =
"obstruction-detected"
19 COMMANDS_STOP: list[OverkizCommand] = [
23 COMMANDS_STOP_TILT: list[OverkizCommand] = [
27 COMMANDS_OPEN: list[OverkizCommand] = [
31 COMMANDS_OPEN_TILT: list[OverkizCommand] = [
32 OverkizCommand.OPEN_SLATS,
33 OverkizCommand.TILT_DOWN,
35 COMMANDS_CLOSE: list[OverkizCommand] = [
39 COMMANDS_CLOSE_TILT: list[OverkizCommand] = [
40 OverkizCommand.CLOSE_SLATS,
41 OverkizCommand.TILT_UP,
44 COMMANDS_SET_TILT_POSITION: list[OverkizCommand] = [OverkizCommand.SET_ORIENTATION]
48 """Representation of an Overkiz Cover."""
52 """Return current position of cover tilt.
54 None is unknown, 0 is closed, 100 is fully open.
56 position = self.
executorexecutor.select_state(
57 OverkizState.CORE_SLATS_ORIENTATION, OverkizState.CORE_SLATE_ORIENTATION
59 if position
is not None:
60 return 100 - cast(int, position)
65 """Move the cover tilt to a specific position."""
66 if command := self.
executorexecutor.select_command(*COMMANDS_SET_TILT_POSITION):
67 await self.
executorexecutor.async_execute_command(
69 100 - kwargs[ATTR_TILT_POSITION],
74 """Return if the cover is closed."""
76 state = self.
executorexecutor.select_state(
77 OverkizState.CORE_OPEN_CLOSED,
78 OverkizState.CORE_SLATS_OPEN_CLOSED,
79 OverkizState.CORE_OPEN_CLOSED_PARTIAL,
80 OverkizState.CORE_OPEN_CLOSED_PEDESTRIAN,
81 OverkizState.CORE_OPEN_CLOSED_UNKNOWN,
82 OverkizState.MYFOX_SHUTTER_STATUS,
85 return state == OverkizCommandParam.CLOSED
97 """Open the cover tilt."""
98 if command := self.
executorexecutor.select_command(*COMMANDS_OPEN_TILT):
99 await self.
executorexecutor.async_execute_command(command)
102 """Close the cover tilt."""
103 if command := self.
executorexecutor.select_command(*COMMANDS_CLOSE_TILT):
104 await self.
executorexecutor.async_execute_command(command)
107 """Stop the cover."""
108 if command := self.
executorexecutor.select_command(*COMMANDS_STOP):
109 await self.
executorexecutor.async_execute_command(command)
112 """Stop the cover tilt."""
113 if command := self.
executorexecutor.select_command(*COMMANDS_STOP_TILT):
114 await self.
executorexecutor.async_execute_command(command)
116 def is_running(self, commands: list[OverkizCommand]) -> bool:
117 """Return if the given commands are currently running."""
119 execution.get(
"device_url") == self.
devicedevice.device_url
120 and execution.get(
"command_name")
in commands
121 for execution
in self.coordinator.executions.values()
126 """Flag supported features."""
129 if self.
executorexecutor.has_command(*COMMANDS_OPEN_TILT):
130 supported_features |= CoverEntityFeature.OPEN_TILT
132 if self.
executorexecutor.has_command(*COMMANDS_STOP_TILT):
133 supported_features |= CoverEntityFeature.STOP_TILT
135 if self.
executorexecutor.has_command(*COMMANDS_CLOSE_TILT):
136 supported_features |= CoverEntityFeature.CLOSE_TILT
138 if self.
executorexecutor.has_command(*COMMANDS_SET_TILT_POSITION):
139 supported_features |= CoverEntityFeature.SET_TILT_POSITION
141 return supported_features
int|None current_cover_tilt_position(self)
current_cover_tilt_position
int|None current_cover_position(self)
current_cover_tilt_position
None async_stop_cover_tilt(self, **Any kwargs)
CoverEntityFeature supported_features(self)
bool|None is_closed(self)
bool is_running(self, list[OverkizCommand] commands)
int|None current_cover_tilt_position(self)
None async_stop_cover(self, **Any kwargs)
None async_close_cover_tilt(self, **Any kwargs)
None async_set_cover_tilt_position(self, **Any kwargs)
None async_open_cover_tilt(self, **Any kwargs)