mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Address Overkiz switch feedback (#68813)
This commit is contained in:
parent
47ecc73dfa
commit
2be8b07af9
@ -1,7 +1,7 @@
|
|||||||
"""Support for Overkiz switches."""
|
"""Support for Overkiz switches."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Awaitable, Callable
|
from collections.abc import Callable
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ from .entity import OverkizDescriptiveEntity
|
|||||||
class OverkizSwitchDescriptionMixin:
|
class OverkizSwitchDescriptionMixin:
|
||||||
"""Define an entity description mixin for switch entities."""
|
"""Define an entity description mixin for switch entities."""
|
||||||
|
|
||||||
turn_on: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
|
turn_on: str
|
||||||
turn_off: Callable[[Callable[..., Awaitable[None]]], Awaitable[None]]
|
turn_off: str
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -38,17 +38,17 @@ class OverkizSwitchDescription(SwitchEntityDescription, OverkizSwitchDescription
|
|||||||
"""Class to describe an Overkiz switch."""
|
"""Class to describe an Overkiz switch."""
|
||||||
|
|
||||||
is_on: Callable[[Callable[[str], OverkizStateType]], bool] | None = None
|
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] = [
|
SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.DOMESTIC_HOT_WATER_TANK,
|
key=UIWidget.DOMESTIC_HOT_WATER_TANK,
|
||||||
turn_on=lambda execute_command: execute_command(
|
turn_on=OverkizCommand.SET_FORCE_HEATING,
|
||||||
OverkizCommand.SET_FORCE_HEATING, OverkizCommandParam.ON
|
turn_on_args=OverkizCommandParam.ON,
|
||||||
),
|
turn_off=OverkizCommand.SET_FORCE_HEATING,
|
||||||
turn_off=lambda execute_command: execute_command(
|
turn_off_args=OverkizCommandParam.OFF,
|
||||||
OverkizCommand.SET_FORCE_HEATING, OverkizCommandParam.OFF
|
|
||||||
),
|
|
||||||
is_on=lambda select_state: (
|
is_on=lambda select_state: (
|
||||||
select_state(OverkizState.IO_FORCE_HEATING) == OverkizCommandParam.ON
|
select_state(OverkizState.IO_FORCE_HEATING) == OverkizCommandParam.ON
|
||||||
),
|
),
|
||||||
@ -56,8 +56,8 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIClass.ON_OFF,
|
key=UIClass.ON_OFF,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
turn_on=OverkizCommand.ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
turn_off=OverkizCommand.OFF,
|
||||||
is_on=lambda select_state: (
|
is_on=lambda select_state: (
|
||||||
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
||||||
),
|
),
|
||||||
@ -65,8 +65,8 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIClass.SWIMMING_POOL,
|
key=UIClass.SWIMMING_POOL,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
turn_on=OverkizCommand.ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
turn_off=OverkizCommand.OFF,
|
||||||
is_on=lambda select_state: (
|
is_on=lambda select_state: (
|
||||||
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
select_state(OverkizState.CORE_ON_OFF) == OverkizCommandParam.ON
|
||||||
),
|
),
|
||||||
@ -74,33 +74,33 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
|
|||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.RTD_INDOOR_SIREN,
|
key=UIWidget.RTD_INDOOR_SIREN,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
turn_on=OverkizCommand.ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
turn_off=OverkizCommand.OFF,
|
||||||
icon="mdi:bell",
|
icon="mdi:bell",
|
||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.RTD_OUTDOOR_SIREN,
|
key=UIWidget.RTD_OUTDOOR_SIREN,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
turn_on=OverkizCommand.ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
turn_off=OverkizCommand.OFF,
|
||||||
icon="mdi:bell",
|
icon="mdi:bell",
|
||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.STATELESS_ALARM_CONTROLLER,
|
key=UIWidget.STATELESS_ALARM_CONTROLLER,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ALARM_ON),
|
turn_on=OverkizCommand.ALARM_ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.ALARM_OFF),
|
turn_off=OverkizCommand.ALARM_OFF,
|
||||||
icon="mdi:shield-lock",
|
icon="mdi:shield-lock",
|
||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.STATELESS_EXTERIOR_HEATING,
|
key=UIWidget.STATELESS_EXTERIOR_HEATING,
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.ON),
|
turn_on=OverkizCommand.ON,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.OFF),
|
turn_off=OverkizCommand.OFF,
|
||||||
icon="mdi:radiator",
|
icon="mdi:radiator",
|
||||||
),
|
),
|
||||||
OverkizSwitchDescription(
|
OverkizSwitchDescription(
|
||||||
key=UIWidget.MY_FOX_SECURITY_CAMERA,
|
key=UIWidget.MY_FOX_SECURITY_CAMERA,
|
||||||
name="Camera Shutter",
|
name="Camera Shutter",
|
||||||
turn_on=lambda execute_command: execute_command(OverkizCommand.OPEN),
|
turn_on=OverkizCommand.OPEN,
|
||||||
turn_off=lambda execute_command: execute_command(OverkizCommand.CLOSE),
|
turn_off=OverkizCommand.CLOSE,
|
||||||
icon="mdi:camera-lock",
|
icon="mdi:camera-lock",
|
||||||
is_on=lambda select_state: (
|
is_on=lambda select_state: (
|
||||||
select_state(OverkizState.MYFOX_SHUTTER_STATUS)
|
select_state(OverkizState.MYFOX_SHUTTER_STATUS)
|
||||||
@ -154,8 +154,14 @@ class OverkizSwitch(OverkizDescriptiveEntity, SwitchEntity):
|
|||||||
|
|
||||||
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."""
|
||||||
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:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn the entity off."""
|
"""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…
x
Reference in New Issue
Block a user