Remove Overkiz switch platform todo and add 2 devices (#66069)

This commit is contained in:
Mick Vleeshouwer 2022-02-08 04:05:35 -08:00 committed by GitHub
parent f74706a265
commit dcab9a19d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -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_INDOOR_SIREN: Platform.SWITCH, # widgetName, uiClass is Siren (not supported)
UIWidget.RTD_OUTDOOR_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.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 # Map Overkiz camelCase to Home Assistant snake_case for translation

View File

@ -30,13 +30,14 @@ class OverkizSwitchDescriptionMixin:
turn_on: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]] turn_on: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
turn_off: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]] turn_off: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
is_on: Callable[[Callable[[str], OverkizStateType]], bool]
@dataclass @dataclass
class OverkizSwitchDescription(SwitchEntityDescription, OverkizSwitchDescriptionMixin): class OverkizSwitchDescription(SwitchEntityDescription, OverkizSwitchDescriptionMixin):
"""Class to describe an Overkiz switch.""" """Class to describe an Overkiz switch."""
is_on: Callable[[Callable[[str], OverkizStateType]], bool] | None = None
SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
OverkizSwitchDescription( OverkizSwitchDescription(
@ -75,14 +76,24 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
turn_on=lambda execute_command: execute_command(OverkizCommand.ON), turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF), turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
icon="mdi:bell", icon="mdi:bell",
is_on=lambda select_state: False, # Remove when is_on in SwitchEntity doesn't require a bool value anymore
), ),
OverkizSwitchDescription( OverkizSwitchDescription(
key=UIWidget.RTD_OUTDOOR_SIREN, key=UIWidget.RTD_OUTDOOR_SIREN,
turn_on=lambda execute_command: execute_command(OverkizCommand.ON), turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF), turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
icon="mdi:bell", 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 entity_description: OverkizSwitchDescription
@property @property
def is_on(self) -> bool: def is_on(self) -> bool | None:
"""Return True if entity is on.""" """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: async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the entity on.""" """Turn the entity on."""