Address Overkiz switch feedback (#68813)
This commit is contained in:
parent
47ecc73dfa
commit
2be8b07af9
1 changed files with 31 additions and 25 deletions
|
@ -1,7 +1,7 @@
|
|||
"""Support for Overkiz switches."""
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Awaitable, Callable
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
|
@ -29,8 +29,8 @@ from .entity import OverkizDescriptiveEntity
|
|||
class OverkizSwitchDescriptionMixin:
|
||||
"""Define an entity description mixin for switch entities."""
|
||||
|
||||
turn_on: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
|
||||
turn_off: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
|
||||
turn_on: str
|
||||
turn_off: str
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -38,17 +38,17 @@ class OverkizSwitchDescription(SwitchEntityDescription, OverkizSwitchDescription
|
|||
"""Class to describe an Overkiz switch."""
|
||||
|
||||
is_on: Callable[[Callable[[str], OverkizStateType]], bool] | None = None
|
||||
turn_on_args: OverkizStateType | list[OverkizStateType] | None = None
|
||||
turn_off_args: OverkizStateType | list[OverkizStateType] | None = None
|
||||
|
||||
|
||||
SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
||||
OverkizSwitchDescription(
|
||||
key=UIWidget.DOMESTIC_HOT_WATER_TANK,
|
||||
turn_on=lambda execute_command: execute_command(
|
||||
OverkizCommand.SET_FORCE_HEATING, OverkizCommandParam.ON
|
||||
),
|
||||
turn_off=lambda execute_command: execute_command(
|
||||
OverkizCommand.SET_FORCE_HEATING, OverkizCommandParam.OFF
|
||||
),
|
||||
turn_on=OverkizCommand.SET_FORCE_HEATING,
|
||||
turn_on_args=OverkizCommandParam.ON,
|
||||
turn_off=OverkizCommand.SET_FORCE_HEATING,
|
||||
turn_off_args=OverkizCommandParam.OFF,
|
||||
is_on=lambda select_state: (
|
||||
select_state(OverkizState.IO_FORCE_HEATING) == OverkizCommandParam.ON
|
||||
),
|
||||
|
@ -56,8 +56,8 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||
),
|
||||
OverkizSwitchDescription(
|
||||
key=UIClass.ON_OFF,
|
||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
||||
turn_on=OverkizCommand.ON,
|
||||
turn_off=OverkizCommand.OFF,
|
||||
is_on=lambda select_state: (
|
||||
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
||||
),
|
||||
|
@ -65,8 +65,8 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||
),
|
||||
OverkizSwitchDescription(
|
||||
key=UIClass.SWIMMING_POOL,
|
||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
||||
turn_on=OverkizCommand.ON,
|
||||
turn_off=OverkizCommand.OFF,
|
||||
is_on=lambda select_state: (
|
||||
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
||||
),
|
||||
|
@ -74,33 +74,33 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||
),
|
||||
OverkizSwitchDescription(
|
||||
key=UIWidget.RTD_INDOOR_SIREN,
|
||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
||||
turn_on=OverkizCommand.ON,
|
||||
turn_off=OverkizCommand.OFF,
|
||||
icon="mdi:bell",
|
||||
),
|
||||
OverkizSwitchDescription(
|
||||
key=UIWidget.RTD_OUTDOOR_SIREN,
|
||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
||||
turn_on=OverkizCommand.ON,
|
||||
turn_off=OverkizCommand.OFF,
|
||||
icon="mdi:bell",
|
||||
),
|
||||
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),
|
||||
turn_on=OverkizCommand.ALARM_ON,
|
||||
turn_off=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),
|
||||
turn_on=OverkizCommand.ON,
|
||||
turn_off=OverkizCommand.OFF,
|
||||
icon="mdi:radiator",
|
||||
),
|
||||
OverkizSwitchDescription(
|
||||
key=UIWidget.MY_FOX_SECURITY_CAMERA,
|
||||
name="Camera Shutter",
|
||||
turn_on=lambda execute_command: execute_command(OverkizCommand.OPEN),
|
||||
turn_off=lambda execute_command: execute_command(OverkizCommand.CLOSE),
|
||||
turn_on=OverkizCommand.OPEN,
|
||||
turn_off=OverkizCommand.CLOSE,
|
||||
icon="mdi:camera-lock",
|
||||
is_on=lambda select_state: (
|
||||
select_state(OverkizState.MYFOX_SHUTTER_STATUS)
|
||||
|
@ -154,8 +154,14 @@ class OverkizSwitch(OverkizDescriptiveEntity, SwitchEntity):
|
|||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
await self.entity_description.turn_on(self.executor.async_execute_command)
|
||||
await self.executor.async_execute_command(
|
||||
self.entity_description.turn_on,
|
||||
self.entity_description.turn_on_args,
|
||||
)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
await self.entity_description.turn_off(self.executor.async_execute_command)
|
||||
await self.executor.async_execute_command(
|
||||
self.entity_description.turn_off,
|
||||
self.entity_description.turn_off_args,
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue