From bc6ee98315343bd6b916dd404572448212670ec4 Mon Sep 17 00:00:00 2001 From: Christian Fetzer Date: Sat, 2 Sep 2023 13:46:35 +0200 Subject: [PATCH] overkiz: Add select for partial position (garage door) The Somfy Dexxo smart io (io:DiscreteGarageOpenerWithPartialPositionIOComponent) supports a third position state: partial. This state is meant to be used to ventilate the garage. This commit adds a select entity for the position state. The implementation is very similar to the already existing position state for gate's with a pedestrian position. Note: For the updates to work properly, we'd still need https://github.com/iMicknl/ha-tahoma/issues/167 / https://github.com/iMicknl/ha-tahoma/pull/271 to be implemented. See https://github.com/Somfy-Developer/Somfy-TaHoma-Developer-Mode/issues/26 for discussion with Somfy. --- homeassistant/components/overkiz/select.py | 23 +++++++++++++++++++ homeassistant/components/overkiz/strings.json | 7 ++++++ 2 files changed, 30 insertions(+) diff --git a/homeassistant/components/overkiz/select.py b/homeassistant/components/overkiz/select.py index 155fc3a538f3d9..56349f23312270 100644 --- a/homeassistant/components/overkiz/select.py +++ b/homeassistant/components/overkiz/select.py @@ -41,6 +41,17 @@ def _select_option_open_closed_pedestrian( }[OverkizCommandParam(option)] ) +def _select_option_open_closed_partial( + option: str, execute_command: Callable[..., Awaitable[None]] +) -> Awaitable[None]: + """Change the selected option for Open/Closed/Partial.""" + return execute_command( + { + OverkizCommandParam.CLOSED: OverkizCommand.CLOSE, + OverkizCommandParam.OPEN: OverkizCommand.OPEN, + OverkizCommandParam.PARTIAL: "setPartialPosition", # FIXME + }[OverkizCommandParam(option)] + ) def _select_option_memorized_simple_volume( option: str, execute_command: Callable[..., Awaitable[None]] @@ -73,6 +84,18 @@ def _select_option_active_zone( select_option=_select_option_open_closed_pedestrian, translation_key="open_closed_pedestrian", ), + OverkizSelectDescription( + key=OverkizState.CORE_OPEN_CLOSED_PARTIAL, + name="Position", + icon="mdi:content-save-cog", + options=[ + OverkizCommandParam.OPEN, + OverkizCommandParam.PARTIAL, + OverkizCommandParam.CLOSED, + ], + select_option=_select_option_open_closed_partial, + translation_key="open_closed_partial", + ), OverkizSelectDescription( key=OverkizState.IO_MEMORIZED_SIMPLE_VOLUME, name="Memorized simple volume", diff --git a/homeassistant/components/overkiz/strings.json b/homeassistant/components/overkiz/strings.json index bcf1e121f6fab5..82d29a7534a88f 100644 --- a/homeassistant/components/overkiz/strings.json +++ b/homeassistant/components/overkiz/strings.json @@ -64,6 +64,13 @@ "closed": "[%key:common::state::closed%]" } }, + "open_closed_partial": { + "state": { + "open": "[%key:common::state::open%]", + "partial": "Partial", + "closed": "[%key:common::state::closed%]" + } + }, "memorized_simple_volume": { "state": { "highest": "Highest",