1 """Plugwise Select component for Home Assistant."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
12 from .
import PlugwiseConfigEntry
13 from .const
import SelectOptionsType, SelectType
14 from .coordinator
import PlugwiseDataUpdateCoordinator
15 from .entity
import PlugwiseEntity
16 from .util
import plugwise_command
19 @dataclass(frozen=True, kw_only=True)
21 """Class describing Plugwise Select entities."""
24 options_key: SelectOptionsType
29 key=
"select_schedule",
30 translation_key=
"select_schedule",
31 options_key=
"available_schedules",
34 key=
"select_regulation_mode",
35 translation_key=
"regulation_mode",
36 entity_category=EntityCategory.CONFIG,
37 options_key=
"regulation_modes",
40 key=
"select_dhw_mode",
41 translation_key=
"dhw_mode",
42 entity_category=EntityCategory.CONFIG,
43 options_key=
"dhw_modes",
46 key=
"select_gateway_mode",
47 translation_key=
"gateway_mode",
48 entity_category=EntityCategory.CONFIG,
49 options_key=
"gateway_modes",
56 entry: PlugwiseConfigEntry,
57 async_add_entities: AddEntitiesCallback,
59 """Set up the Smile selector from a config entry."""
60 coordinator = entry.runtime_data
63 def _add_entities() -> None:
65 if not coordinator.new_devices:
70 for device_id
in coordinator.new_devices
71 for description
in SELECT_TYPES
72 if description.options_key
in coordinator.data.devices[device_id]
76 entry.async_on_unload(coordinator.async_add_listener(_add_entities))
80 """Represent Smile selector."""
82 entity_description: PlugwiseSelectEntityDescription
86 coordinator: PlugwiseDataUpdateCoordinator,
88 entity_description: PlugwiseSelectEntityDescription,
90 """Initialise the selector."""
91 super().
__init__(coordinator, device_id)
96 if (location := self.
devicedevice.
get(
"location"))
is not None:
101 """Return the selected entity option to represent the entity state."""
106 """Return the available select-options."""
111 """Change to the selected entity option.
113 self._location and STATE_ON are required for the thermostat-schedule select.
115 await self.coordinator.api.set_select(
GwEntityData device(self)
None async_select_option(self, str option)
None __init__(self, PlugwiseDataUpdateCoordinator coordinator, str device_id, PlugwiseSelectEntityDescription entity_description)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, PlugwiseConfigEntry entry, AddEntitiesCallback async_add_entities)