From dcab9a19d610d81b6cbbe21fee4d5a5e586cef6a Mon Sep 17 00:00:00 2001 From: Mick Vleeshouwer Date: Tue, 8 Feb 2022 04:05:35 -0800 Subject: [PATCH] Remove Overkiz switch platform todo and add 2 devices (#66069) --- homeassistant/components/overkiz/const.py | 2 ++ homeassistant/components/overkiz/switch.py | 24 +++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/overkiz/const.py b/homeassistant/components/overkiz/const.py index ba5470724cd..a88706a428f 100644 --- a/homeassistant/components/overkiz/const.py +++ b/homeassistant/components/overkiz/const.py @@ -61,6 +61,8 @@ OVERKIZ_DEVICE_TO_PLATFORM: dict[UIClass | UIWidget, Platform] = { UIWidget.RTD_INDOOR_SIREN: Platform.SWITCH, # widgetName, uiClass is Siren (not supported) UIWidget.RTD_OUTDOOR_SIREN: Platform.SWITCH, # widgetName, uiClass is Siren (not supported) UIWidget.RTS_GENERIC: Platform.COVER, # widgetName, uiClass is Generic (not supported) + UIWidget.STATELESS_ALARM_CONTROLLER: Platform.SWITCH, # widgetName, uiClass is Alarm (not supported) + UIWidget.STATELESS_EXTERIOR_HEATING: Platform.SWITCH, # widgetName, uiClass is ExteriorHeatingSystem (not supported) } # Map Overkiz camelCase to Home Assistant snake_case for translation diff --git a/homeassistant/components/overkiz/switch.py b/homeassistant/components/overkiz/switch.py index 969a9508943..8b3222cf442 100644 --- a/homeassistant/components/overkiz/switch.py +++ b/homeassistant/components/overkiz/switch.py @@ -30,13 +30,14 @@ class OverkizSwitchDescriptionMixin: turn_on: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]] turn_off: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]] - is_on: Callable[[Callable[[str], OverkizStateType]], bool] @dataclass class OverkizSwitchDescription(SwitchEntityDescription, OverkizSwitchDescriptionMixin): """Class to describe an Overkiz switch.""" + is_on: Callable[[Callable[[str], OverkizStateType]], bool] | None = None + SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [ OverkizSwitchDescription( @@ -75,14 +76,24 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [ turn_on=lambda execute_command: execute_command(OverkizCommand.ON), turn_off=lambda execute_command: execute_command(OverkizCommand.OFF), icon="mdi:bell", - is_on=lambda select_state: False, # Remove when is_on in SwitchEntity doesn't require a bool value anymore ), OverkizSwitchDescription( key=UIWidget.RTD_OUTDOOR_SIREN, turn_on=lambda execute_command: execute_command(OverkizCommand.ON), turn_off=lambda execute_command: execute_command(OverkizCommand.OFF), icon="mdi:bell", - is_on=lambda select_state: False, # Remove when is_on in SwitchEntity doesn't require a bool value anymore + ), + OverkizSwitchDescription( + key=UIWidget.STATELESS_ALARM_CONTROLLER, + turn_on=lambda execute_command: execute_command(OverkizCommand.ALARM_ON), + turn_off=lambda execute_command: execute_command(OverkizCommand.ALARM_OFF), + icon="mdi:shield-lock", + ), + OverkizSwitchDescription( + key=UIWidget.STATELESS_EXTERIOR_HEATING, + turn_on=lambda execute_command: execute_command(OverkizCommand.ON), + turn_off=lambda execute_command: execute_command(OverkizCommand.OFF), + icon="mdi:radiator", ), ] @@ -121,9 +132,12 @@ class OverkizSwitch(OverkizDescriptiveEntity, SwitchEntity): entity_description: OverkizSwitchDescription @property - def is_on(self) -> bool: + def is_on(self) -> bool | None: """Return True if entity is on.""" - return self.entity_description.is_on(self.executor.select_state) + if self.entity_description.is_on: + return self.entity_description.is_on(self.executor.select_state) + + return None async def async_turn_on(self, **kwargs: Any) -> None: """Turn the entity on."""