1 """Support for Overkiz awnings."""
3 from __future__
import annotations
5 from typing
import Any, cast
7 from pyoverkiz.enums
import OverkizCommand, OverkizState
15 from .generic_cover
import (
24 """Representation of an Overkiz awning."""
26 _attr_device_class = CoverDeviceClass.AWNING
30 """Flag supported features."""
31 supported_features = super().supported_features
33 if self.
executorexecutor.has_command(OverkizCommand.SET_DEPLOYMENT):
34 supported_features |= CoverEntityFeature.SET_POSITION
36 if self.
executorexecutor.has_command(OverkizCommand.DEPLOY):
37 supported_features |= CoverEntityFeature.OPEN
39 if self.
executorexecutor.has_command(*COMMANDS_STOP):
40 supported_features |= CoverEntityFeature.STOP
42 if self.
executorexecutor.has_command(OverkizCommand.UNDEPLOY):
43 supported_features |= CoverEntityFeature.CLOSE
45 return supported_features
49 """Return current position of cover.
51 None is unknown, 0 is closed, 100 is fully open.
53 current_position = self.
executorexecutor.select_state(OverkizState.CORE_DEPLOYMENT)
54 if current_position
is not None:
55 return cast(int, current_position)
60 """Move the cover to a specific position."""
61 await self.
executorexecutor.async_execute_command(
62 OverkizCommand.SET_DEPLOYMENT, kwargs[ATTR_POSITION]
67 await self.
executorexecutor.async_execute_command(OverkizCommand.DEPLOY)
70 """Close the cover."""
71 await self.
executorexecutor.async_execute_command(OverkizCommand.UNDEPLOY)
75 """Return if the cover is opening or not."""
80 is_moving = self.
devicedevice.states.get(OverkizState.CORE_MOVING)
81 current_closure = self.
devicedevice.states.get(OverkizState.CORE_DEPLOYMENT)
82 target_closure = self.
devicedevice.states.get(OverkizState.CORE_TARGET_CLOSURE)
84 if not is_moving
or not current_closure
or not target_closure:
87 return cast(int, current_closure.value) < cast(int, target_closure.value)
91 """Return if the cover is closing or not."""
96 is_moving = self.
devicedevice.states.get(OverkizState.CORE_MOVING)
97 current_closure = self.
devicedevice.states.get(OverkizState.CORE_DEPLOYMENT)
98 target_closure = self.
devicedevice.states.get(OverkizState.CORE_TARGET_CLOSURE)
100 if not is_moving
or not current_closure
or not target_closure:
103 return cast(int, current_closure.value) > cast(int, target_closure.value)
None async_set_cover_position(self, **Any kwargs)
bool|None is_closing(self)
CoverEntityFeature supported_features(self)
None async_open_cover(self, **Any kwargs)
bool|None is_opening(self)
None async_close_cover(self, **Any kwargs)
bool is_running(self, list[OverkizCommand] commands)