1 """Support for Overkiz select."""
3 from __future__
import annotations
5 from collections.abc
import Awaitable, Callable
6 from dataclasses
import dataclass
8 from pyoverkiz.enums
import OverkizCommand, OverkizCommandParam, OverkizState
16 from .
import HomeAssistantOverkizData
17 from .const
import DOMAIN, IGNORED_OVERKIZ_DEVICES
18 from .entity
import OverkizDescriptiveEntity
21 @dataclass(frozen=True, kw_only=True)
23 """Class to describe an Overkiz select entity."""
25 select_option: Callable[[str, Callable[..., Awaitable[
None]]], Awaitable[
None]]
29 option: str, execute_command: Callable[..., Awaitable[
None]]
31 """Change the selected option for Open/Closed/Pedestrian."""
32 return execute_command(
34 OverkizCommandParam.CLOSED: OverkizCommand.CLOSE,
35 OverkizCommandParam.OPEN: OverkizCommand.OPEN,
36 OverkizCommandParam.PEDESTRIAN: OverkizCommand.SET_PEDESTRIAN_POSITION,
37 }[OverkizCommandParam(option)]
42 option: str, execute_command: Callable[..., Awaitable[
None]]
44 """Change the selected option for Open/Closed/Partial."""
45 return execute_command(
47 OverkizCommandParam.CLOSED: OverkizCommand.CLOSE,
48 OverkizCommandParam.OPEN: OverkizCommand.OPEN,
49 OverkizCommandParam.PARTIAL: OverkizCommand.PARTIAL_POSITION,
50 }[OverkizCommandParam(option)]
55 option: str, execute_command: Callable[..., Awaitable[
None]]
57 """Change the selected option for Memorized Simple Volume."""
58 return execute_command(OverkizCommand.SET_MEMORIZED_SIMPLE_VOLUME, option)
62 option: str, execute_command: Callable[..., Awaitable[
None]]
64 """Change the selected option for Active Zone(s)."""
67 return execute_command(OverkizCommand.ALARM_OFF)
69 return execute_command(OverkizCommand.ALARM_ZONE_ON, option)
72 SELECT_DESCRIPTIONS: list[OverkizSelectDescription] = [
74 key=OverkizState.CORE_OPEN_CLOSED_PEDESTRIAN,
76 icon=
"mdi:content-save-cog",
78 OverkizCommandParam.OPEN,
79 OverkizCommandParam.PEDESTRIAN,
80 OverkizCommandParam.CLOSED,
82 select_option=_select_option_open_closed_pedestrian,
83 translation_key=
"open_closed_pedestrian",
86 key=OverkizState.CORE_OPEN_CLOSED_PARTIAL,
88 icon=
"mdi:content-save-cog",
90 OverkizCommandParam.OPEN,
91 OverkizCommandParam.PARTIAL,
92 OverkizCommandParam.CLOSED,
94 select_option=_select_option_open_closed_partial,
95 translation_key=
"open_closed_partial",
98 key=OverkizState.IO_MEMORIZED_SIMPLE_VOLUME,
99 name=
"Memorized simple volume",
100 icon=
"mdi:volume-high",
101 options=[OverkizCommandParam.STANDARD, OverkizCommandParam.HIGHEST],
102 select_option=_select_option_memorized_simple_volume,
103 entity_category=EntityCategory.CONFIG,
104 translation_key=
"memorized_simple_volume",
108 key=OverkizState.OVP_HEATING_TEMPERATURE_INTERFACE_OPERATING_MODE,
109 name=
"Operating mode",
110 icon=
"mdi:sun-snowflake",
111 options=[OverkizCommandParam.HEATING, OverkizCommandParam.COOLING],
112 select_option=
lambda option, execute_command: execute_command(
113 OverkizCommand.SET_OPERATING_MODE, option
115 entity_category=EntityCategory.CONFIG,
119 key=OverkizState.CORE_ACTIVE_ZONES,
121 icon=
"mdi:shield-lock",
122 options=[
"",
"A",
"B",
"C",
"A,B",
"B,C",
"A,C",
"A,B,C"],
123 select_option=_select_option_active_zone,
127 SUPPORTED_STATES = {description.key: description
for description
in SELECT_DESCRIPTIONS}
133 async_add_entities: AddEntitiesCallback,
135 """Set up the Overkiz select from a config entry."""
136 data: HomeAssistantOverkizData = hass.data[DOMAIN][entry.entry_id]
137 entities: list[OverkizSelect] = []
139 for device
in data.coordinator.data.values():
141 device.widget
in IGNORED_OVERKIZ_DEVICES
142 or device.ui_class
in IGNORED_OVERKIZ_DEVICES
152 for state
in device.definition.states
153 if (description := SUPPORTED_STATES.get(state.qualified_name))
160 """Representation of an Overkiz Select entity."""
162 entity_description: OverkizSelectDescription
166 """Return the selected entity option to represent the entity state."""
168 return str(state.value)
173 """Change the selected option."""
175 option, self.
executorexecutor.async_execute_command
None async_select_option(self, str option)
str|None current_option(self)
None select_option(self, str option)
Awaitable[None] _select_option_active_zone(str option, Callable[..., Awaitable[None]] execute_command)
Awaitable[None] _select_option_open_closed_partial(str option, Callable[..., Awaitable[None]] execute_command)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Awaitable[None] _select_option_open_closed_pedestrian(str option, Callable[..., Awaitable[None]] execute_command)
Awaitable[None] _select_option_memorized_simple_volume(str option, Callable[..., Awaitable[None]] execute_command)