From a3867740b3ad2c8245a70467fc1e08da9bded402 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Tue, 24 May 2022 08:54:01 +0000 Subject: [PATCH 01/11] WIP --- homeassistant/components/overkiz/cover.py | 136 ++++++++++++++++++---- 1 file changed, 116 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 4e741aa68e6de0..cf13a387b7fa08 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -1,6 +1,16 @@ """Support for Overkiz covers - shutters etc.""" -from pyoverkiz.enums import OverkizCommand, UIClass +from dataclasses import dataclass +from typing import Any, Callable, Optional, cast +from xmlrpc.client import boolean +from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState, UIClass +from pyoverkiz.models import Device + +from homeassistant.components.cover import ( + ATTR_POSITION, + CoverEntity, + CoverEntityDescription, +) from homeassistant.config_entries import ConfigEntry from homeassistant.const import Platform from homeassistant.core import HomeAssistant @@ -8,9 +18,50 @@ from . import HomeAssistantOverkizData from .const import DOMAIN -from .cover_entities.awning import Awning -from .cover_entities.generic_cover import OverkizGenericCover -from .cover_entities.vertical_cover import LowSpeedCover, VerticalCover +from .entity import OverkizDescriptiveEntity + + +def is_closed(device: Device) -> boolean: + return device.states[OverkizState.CORE_OPEN_CLOSED] == OverkizCommandParam.CLOSED + + +@dataclass +class OverkizCoverDescription(CoverEntityDescription): + """Class to describe an Overkiz cover.""" + + ui_class: UIClass = None + current_position_state: OverkizState = None + invert_position: boolean = True + set_position_command: OverkizCommand = None + open_command: OverkizCommand = None + close_command: OverkizCommand = None + is_closed_fn: Callable[[Device], bool] = None + stop_command: OverkizCommand = None + + +COVER_DESCRIPTIONS: list[OverkizCoverDescription] = [ + OverkizCoverDescription( + key=UIClass.AWNING, + current_position_state=OverkizState.CORE_DEPLOYMENT, + set_position_command=OverkizCommand.SET_DEPLOYMENT, + open_command=OverkizCommand.DEPLOY, + close_command=OverkizCommand.UNDEPLOY, + invert_position=False, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + ), + OverkizCoverDescription( + key=UIClass.ROLLER_SHUTTER, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + ), +] + +SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} async def async_setup_entry( @@ -18,23 +69,68 @@ async def async_setup_entry( ) -> None: """Set up the Overkiz covers from a config entry.""" data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id] + entities: list[OverkizCover] = [] - entities: list[OverkizGenericCover] = [ - Awning(device.device_url, data.coordinator) - for device in data.platforms[Platform.COVER] - if device.ui_class == UIClass.AWNING - ] + for device in data.platforms[Platform.COVER]: + if description := SUPPORTED_DEVICES.get(device.widget) or SUPPORTED_DEVICES.get( + device.ui_class + ): + entities.append( + OverkizCover( + device.device_url, + data.coordinator, + description, + ) + ) - entities += [ - VerticalCover(device.device_url, data.coordinator) - for device in data.platforms[Platform.COVER] - if device.ui_class != UIClass.AWNING - ] + async_add_entities(entities) - entities += [ - LowSpeedCover(device.device_url, data.coordinator) - for device in data.platforms[Platform.COVER] - if OverkizCommand.SET_CLOSURE_AND_LINEAR_SPEED in device.definition.commands - ] - async_add_entities(entities) +class OverkizCover(OverkizDescriptiveEntity, CoverEntity): + """Representation of an Overkiz Cover.""" + + @property + def is_closed(self) -> Optional[boolean]: + self.entity_description.is_closed_fn(self.device) + + @property + def current_cover_position(self) -> Optional[int]: + """ + Return current position of cover. + + None is unknown, 0 is closed, 100 is fully open. + """ + position = None + if current_state := self.device.states[ + self.entity_description.current_position_state + ]: + position = current_state.value + + if self.entity_description.invert_position: + position = 100 - position + + return cast(int, position) + + async def async_set_cover_position(self, **kwargs: Any) -> None: + """Move the cover to a specific position.""" + position = kwargs[ATTR_POSITION] + if self.entity_description.invert_position: + position = 100 - position + + if command := self.entity_description.set_position_command: + await self.executor.async_execute_command(command, position) + + async def async_open_cover(self, **kwargs: Any) -> None: + """Open the cover.""" + if command := self.entity_description.open_command: + await self.executor.async_execute_command(command) + + async def async_close_cover(self, **kwargs: Any) -> None: + """Close the cover.""" + if command := self.entity_description.close_command: + await self.executor.async_execute_command(command) + + async def async_stop_cover(self, **kwargs: Any) -> None: + """Stop the cover.""" + if command := self.entity_description.stop_command: + await self.executor.async_execute_command(command) From 682c4e41bc789b5a81e9e0afe75e88c0620ebf7b Mon Sep 17 00:00:00 2001 From: Thibaut Date: Tue, 24 May 2022 10:39:24 +0000 Subject: [PATCH 02/11] Fix typing --- homeassistant/components/overkiz/cover.py | 59 +++++++++++++++-------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index cf13a387b7fa08..ff71dec752a4f5 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -1,6 +1,9 @@ """Support for Overkiz covers - shutters etc.""" +from __future__ import annotations + +from collections.abc import Callable from dataclasses import dataclass -from typing import Any, Callable, Optional, cast +from typing import Any, cast from xmlrpc.client import boolean from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState, UIClass @@ -22,21 +25,31 @@ def is_closed(device: Device) -> boolean: - return device.states[OverkizState.CORE_OPEN_CLOSED] == OverkizCommandParam.CLOSED + """Return if the cover is closed.""" + + if state := device.states[OverkizState.CORE_OPEN_CLOSED]: + return state.value == OverkizCommandParam.CLOSED + + return False @dataclass -class OverkizCoverDescription(CoverEntityDescription): +class OverkizCoverDescriptionMixin: + """Define an entity description mixin for cover entities.""" + + open_command: OverkizCommand + close_command: OverkizCommand + stop_command: OverkizCommand + + +@dataclass +class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMixin): """Class to describe an Overkiz cover.""" - ui_class: UIClass = None - current_position_state: OverkizState = None + current_position_state: OverkizState | None = None invert_position: boolean = True - set_position_command: OverkizCommand = None - open_command: OverkizCommand = None - close_command: OverkizCommand = None - is_closed_fn: Callable[[Device], bool] = None - stop_command: OverkizCommand = None + set_position_command: OverkizCommand | None = None + is_closed_fn: Callable[[Device], bool] | None = None COVER_DESCRIPTIONS: list[OverkizCoverDescription] = [ @@ -89,27 +102,35 @@ async def async_setup_entry( class OverkizCover(OverkizDescriptiveEntity, CoverEntity): """Representation of an Overkiz Cover.""" + entity_description: OverkizCoverDescription + @property - def is_closed(self) -> Optional[boolean]: - self.entity_description.is_closed_fn(self.device) + def is_closed(self) -> boolean | None: + """Return if the cover is closed.""" + + if is_closed_fn := self.entity_description.is_closed_fn: + return is_closed_fn(self.device) + return None @property - def current_cover_position(self) -> Optional[int]: + def current_cover_position(self) -> int | None: """ Return current position of cover. None is unknown, 0 is closed, 100 is fully open. """ - position = None - if current_state := self.device.states[ - self.entity_description.current_position_state - ]: - position = current_state.value + state_name = self.entity_description.current_position_state + + if not state_name: + return None + + if state := self.device.states[state_name]: + position = cast(int, state.value) if self.entity_description.invert_position: position = 100 - position - return cast(int, position) + return position async def async_set_cover_position(self, **kwargs: Any) -> None: """Move the cover to a specific position.""" From 84e3e6dba898a6a868a264ef745cc4b5f990c460 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Tue, 24 May 2022 11:01:03 +0000 Subject: [PATCH 03/11] Add is_running and is_closing --- homeassistant/components/overkiz/cover.py | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index ff71dec752a4f5..4d67e7361b4b34 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -11,6 +11,7 @@ from homeassistant.components.cover import ( ATTR_POSITION, + CoverDeviceClass, CoverEntity, CoverEntityDescription, ) @@ -62,6 +63,7 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix invert_position=False, is_closed_fn=is_closed, stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.AWNING, ), OverkizCoverDescription( key=UIClass.ROLLER_SHUTTER, @@ -71,6 +73,7 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix close_command=OverkizCommand.CLOSE, is_closed_fn=is_closed, stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.SHUTTER, ), ] @@ -155,3 +158,54 @@ async def async_stop_cover(self, **kwargs: Any) -> None: """Stop the cover.""" if command := self.entity_description.stop_command: await self.executor.async_execute_command(command) + + @property + def is_opening(self) -> bool | None: + """Return if the cover is opening or not.""" + + if command := self.entity_description.open_command: + if self.is_running(command): + return True + + if self.moving_offset is None: + return None + + if self.entity_description.invert_position: + return self.moving_offset > 0 + return self.moving_offset < 0 + + @property + def is_closing(self) -> bool | None: + """Return if the cover is opening or not.""" + + if command := self.entity_description.close_command: + if self.is_running(command): + return True + + if self.moving_offset is None: + return None + + if self.entity_description.invert_position: + return self.moving_offset < 0 + return self.moving_offset > 0 + + def is_running(self, command: OverkizCommand) -> bool: + """Return if the given commands are currently running.""" + return any( + execution.get("device_url") == self.device.device_url + and execution.get("command_name") == command + for execution in self.coordinator.executions.values() + ) + + @property + def moving_offset(self) -> int | None: + """Return the offset between the targeted position and the current one if the cover is moving.""" + + is_moving = self.device.states.get(OverkizState.CORE_MOVING) + current_closure = self.device.states.get(OverkizState.CORE_CLOSURE) + target_closure = self.device.states.get(OverkizState.CORE_TARGET_CLOSURE) + + if not is_moving or not current_closure or not target_closure: + return None + + return cast(int, current_closure.value) - cast(int, target_closure.value) From 1b12c0cf2bdcb09bfbeb3d62821348448dba4279 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 25 May 2022 06:52:46 +0000 Subject: [PATCH 04/11] Add support for AdjustableSlatsRollerShutter --- homeassistant/components/overkiz/cover.py | 56 +++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 4d67e7361b4b34..d98abc7a775186 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -11,6 +11,7 @@ from homeassistant.components.cover import ( ATTR_POSITION, + ATTR_TILT_POSITION, CoverDeviceClass, CoverEntity, CoverEntityDescription, @@ -51,6 +52,11 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix invert_position: boolean = True set_position_command: OverkizCommand | None = None is_closed_fn: Callable[[Device], bool] | None = None + current_tilt_position: OverkizState | None = None + set_tilt_position_command: OverkizCommand | None = None + open_tilt_command: OverkizCommand | None = None + close_tilt_command: OverkizCommand | None = None + stop_tilt_command: OverkizCommand | None = None COVER_DESCRIPTIONS: list[OverkizCoverDescription] = [ @@ -75,6 +81,19 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix stop_command=OverkizCommand.STOP, device_class=CoverDeviceClass.SHUTTER, ), + OverkizCoverDescription( + key=UIClass.ADJUSTABLE_SLATS_ROLLER_SHUTTER, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + current_tilt_position=OverkizState.CORE_SLATE_ORIENTATION, + set_tilt_position_command=OverkizCommand.SET_ORIENTATION, + stop_tilt_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.SHUTTER, + ), ] SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} @@ -159,6 +178,43 @@ async def async_stop_cover(self, **kwargs: Any) -> None: if command := self.entity_description.stop_command: await self.executor.async_execute_command(command) + @property + def current_cover_tilt_position(self) -> int | None: + """Return current position of cover tilt. + + None is unknown, 0 is closed, 100 is fully open. + """ + state_name = self.entity_description.current_position_state + + if not state_name: + return None + + if state := self.device.states[state_name]: + return cast(int, state.value) + + return None + + async def async_set_cover_tilt_position(self, **kwargs: Any) -> None: + """Move the cover tilt to a specific position.""" + position = kwargs[ATTR_TILT_POSITION] + if command := self.entity_description.set_tilt_position_command: + await self.executor.async_execute_command(command, position) + + async def async_open_tilt_cover(self, **kwargs: Any) -> None: + """Open the cover tilt.""" + if command := self.entity_description.open_tilt_command: + await self.executor.async_execute_command(command) + + async def async_close_tilt_cover(self, **kwargs: Any) -> None: + """Close the cover tilt.""" + if command := self.entity_description.close_tilt_command: + await self.executor.async_execute_command(command) + + async def async_stop_tilt_cover(self, **kwargs: Any) -> None: + """Stop the cover tilt.""" + if command := self.entity_description.stop_tilt_command: + await self.executor.async_execute_command(command) + @property def is_opening(self) -> bool | None: """Return if the cover is opening or not.""" From d2ac83c090f6b87066e3d1d312fa8bc044ac4b3d Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 25 May 2022 07:24:38 +0000 Subject: [PATCH 05/11] Add curtain support --- homeassistant/components/overkiz/cover.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index d98abc7a775186..ef53e735719c2e 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -4,7 +4,6 @@ from collections.abc import Callable from dataclasses import dataclass from typing import Any, cast -from xmlrpc.client import boolean from pyoverkiz.enums import OverkizCommand, OverkizCommandParam, OverkizState, UIClass from pyoverkiz.models import Device @@ -26,7 +25,7 @@ from .entity import OverkizDescriptiveEntity -def is_closed(device: Device) -> boolean: +def is_closed(device: Device) -> bool | None: """Return if the cover is closed.""" if state := device.states[OverkizState.CORE_OPEN_CLOSED]: @@ -49,9 +48,9 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix """Class to describe an Overkiz cover.""" current_position_state: OverkizState | None = None - invert_position: boolean = True + invert_position: bool = True set_position_command: OverkizCommand | None = None - is_closed_fn: Callable[[Device], bool] | None = None + is_closed_fn: Callable[[Device], bool | None] | None = None current_tilt_position: OverkizState | None = None set_tilt_position_command: OverkizCommand | None = None open_tilt_command: OverkizCommand | None = None @@ -87,12 +86,19 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix set_position_command=OverkizCommand.SET_CLOSURE, open_command=OverkizCommand.OPEN, close_command=OverkizCommand.CLOSE, - is_closed_fn=is_closed, stop_command=OverkizCommand.STOP, current_tilt_position=OverkizState.CORE_SLATE_ORIENTATION, set_tilt_position_command=OverkizCommand.SET_ORIENTATION, stop_tilt_command=OverkizCommand.STOP, - device_class=CoverDeviceClass.SHUTTER, + device_class=CoverDeviceClass.BLIND, + ), + OverkizCoverDescription( + key=UIClass.CURTAIN, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.CURTAIN, ), ] @@ -127,11 +133,14 @@ class OverkizCover(OverkizDescriptiveEntity, CoverEntity): entity_description: OverkizCoverDescription @property - def is_closed(self) -> boolean | None: + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if is_closed_fn := self.entity_description.is_closed_fn: return is_closed_fn(self.device) + + # Fallback to self.current_cover_position == 0 ? + return None @property From dbe107bd511622267ebc9290c5055c7ad013d2f2 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 25 May 2022 07:27:44 +0000 Subject: [PATCH 06/11] Add support for Exterior Screen --- homeassistant/components/overkiz/cover.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index ef53e735719c2e..7d241863d0031c 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -100,6 +100,16 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix stop_command=OverkizCommand.STOP, device_class=CoverDeviceClass.CURTAIN, ), + OverkizCoverDescription( + key=UIClass.EXTERIOR_SCREEN, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.BLIND, + ), ] SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} From bddf202c951aa15977711bfe2f05190d46401cb3 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 25 May 2022 07:34:49 +0000 Subject: [PATCH 07/11] Add support for Exterior Venitian Blind --- homeassistant/components/overkiz/cover.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 7d241863d0031c..8a425e0cd1e555 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -80,7 +80,7 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix stop_command=OverkizCommand.STOP, device_class=CoverDeviceClass.SHUTTER, ), - OverkizCoverDescription( + OverkizCoverDescription( # To check, it looks like this device can only tilt. Ask help from an owner key=UIClass.ADJUSTABLE_SLATS_ROLLER_SHUTTER, current_position_state=OverkizState.CORE_CLOSURE, set_position_command=OverkizCommand.SET_CLOSURE, @@ -110,6 +110,19 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix stop_command=OverkizCommand.STOP, device_class=CoverDeviceClass.BLIND, ), + OverkizCoverDescription( + key=UIClass.EXTERIOR_VENETIAN_BLIND, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + current_tilt_position=OverkizState.CORE_SLATE_ORIENTATION, + set_tilt_position_command=OverkizCommand.SET_ORIENTATION, + stop_tilt_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.BLIND, + ), ] SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} From 9405f3996bce3ca33e9e7973163f2dbb41dc8bc7 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Wed, 25 May 2022 07:39:29 +0000 Subject: [PATCH 08/11] Add TODO --- homeassistant/components/overkiz/cover.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 8a425e0cd1e555..712f1bdb7d1003 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -125,6 +125,18 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix ), ] +""" + TODO + UIClass.GARAGE_DOOR: Platform.COVER, + UIClass.GATE: Platform.COVER, + UIClass.PERGOLA: Platform.COVER, + UIClass.SCREEN: Platform.COVER, + UIClass.SHUTTER: Platform.COVER, + UIClass.SWINGING_SHUTTER: Platform.COVER, + UIClass.VENETIAN_BLIND: Platform.COVER, + UIWidget.RTS_GENERIC: Platform.COVER, # widgetName, uiClass is Generic (not supported) + """ + SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} From 8c8a3839200432a8ccf85d57103d7bda2d17a9e7 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 30 May 2022 19:42:23 +0000 Subject: [PATCH 09/11] Add support for Pergola --- homeassistant/components/overkiz/cover.py | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 712f1bdb7d1003..97f3470c350155 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -35,18 +35,12 @@ def is_closed(device: Device) -> bool | None: @dataclass -class OverkizCoverDescriptionMixin: - """Define an entity description mixin for cover entities.""" - - open_command: OverkizCommand - close_command: OverkizCommand - stop_command: OverkizCommand - - -@dataclass -class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMixin): +class OverkizCoverDescription(CoverEntityDescription): """Class to describe an Overkiz cover.""" + open_command: OverkizCommand | None = None + close_command: OverkizCommand | None = None + stop_command: OverkizCommand | None = None current_position_state: OverkizState | None = None invert_position: bool = True set_position_command: OverkizCommand | None = None @@ -123,13 +117,21 @@ class OverkizCoverDescription(CoverEntityDescription, OverkizCoverDescriptionMix stop_tilt_command=OverkizCommand.STOP, device_class=CoverDeviceClass.BLIND, ), + OverkizCoverDescription( + key=UIClass.PERGOLA, + current_tilt_position=OverkizState.CORE_SLATE_ORIENTATION, + set_tilt_position_command=OverkizCommand.SET_ORIENTATION, + open_tilt_command=OverkizCommand.OPEN_SLATS, + close_tilt_command=OverkizCommand.CLOSE_SLATS, + stop_tilt_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.AWNING, + ), ] """ TODO UIClass.GARAGE_DOOR: Platform.COVER, UIClass.GATE: Platform.COVER, - UIClass.PERGOLA: Platform.COVER, UIClass.SCREEN: Platform.COVER, UIClass.SHUTTER: Platform.COVER, UIClass.SWINGING_SHUTTER: Platform.COVER, From 1807d1b2c8ae536f8d305e6d34746d6a0359929d Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 25 Jul 2022 06:48:12 +0000 Subject: [PATCH 10/11] Add more devices --- homeassistant/components/overkiz/cover.py | 46 +++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index 97f3470c350155..e63debf837a162 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -126,17 +126,49 @@ class OverkizCoverDescription(CoverEntityDescription): stop_tilt_command=OverkizCommand.STOP, device_class=CoverDeviceClass.AWNING, ), + OverkizCoverDescription( + key=UIClass.GARAGE_DOOR, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.GARAGE, + ), + OverkizCoverDescription( + key=UIClass.SCREEN, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.BLIND, + ), + OverkizCoverDescription( + key=UIClass.SHUTTER, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.SHUTTER, + ), + OverkizCoverDescription( + key=UIClass.SWINGING_SHUTTER, + current_position_state=OverkizState.CORE_CLOSURE, + set_position_command=OverkizCommand.SET_CLOSURE, + open_command=OverkizCommand.OPEN, + close_command=OverkizCommand.CLOSE, + is_closed_fn=is_closed, + stop_command=OverkizCommand.STOP, + device_class=CoverDeviceClass.SHUTTER, + ), ] """ TODO - UIClass.GARAGE_DOOR: Platform.COVER, - UIClass.GATE: Platform.COVER, - UIClass.SCREEN: Platform.COVER, - UIClass.SHUTTER: Platform.COVER, - UIClass.SWINGING_SHUTTER: Platform.COVER, - UIClass.VENETIAN_BLIND: Platform.COVER, - UIWidget.RTS_GENERIC: Platform.COVER, # widgetName, uiClass is Generic (not supported) + GarageDoor Cyclic: Ask to https://github.com/iMicknl/ha-tahoma/issues/146 """ SUPPORTED_DEVICES = {description.key: description for description in COVER_DESCRIPTIONS} From e69e3858ad5eb41e670670ec46ae740e01b87fcf Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 25 Jul 2022 06:54:05 +0000 Subject: [PATCH 11/11] Enhance Pergola support --- homeassistant/components/overkiz/cover.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/homeassistant/components/overkiz/cover.py b/homeassistant/components/overkiz/cover.py index e63debf837a162..78354436bb4163 100644 --- a/homeassistant/components/overkiz/cover.py +++ b/homeassistant/components/overkiz/cover.py @@ -119,6 +119,12 @@ class OverkizCoverDescription(CoverEntityDescription): ), OverkizCoverDescription( key=UIClass.PERGOLA, + current_position_state=OverkizState.CORE_DEPLOYMENT, + set_position_command=OverkizCommand.SET_DEPLOYMENT, + open_command=OverkizCommand.DEPLOY, + close_command=OverkizCommand.UNDEPLOY, + invert_position=False, + is_closed_fn=is_closed, current_tilt_position=OverkizState.CORE_SLATE_ORIENTATION, set_tilt_position_command=OverkizCommand.SET_ORIENTATION, open_tilt_command=OverkizCommand.OPEN_SLATS,