1 """TOLO Sauna Select controls."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from tololib
import ToloClient, ToloSettings
16 from .const
import DOMAIN, AromaTherapySlot, LampMode
17 from .coordinator
import ToloSaunaUpdateCoordinator
18 from .entity
import ToloSaunaCoordinatorEntity
21 @dataclass(frozen=True, kw_only=True)
23 """Class describing TOLO select entities."""
26 getter: Callable[[ToloSettings], str]
27 setter: Callable[[ToloClient, str], bool]
33 translation_key=
"lamp_mode",
34 options=[lamp_mode.name.lower()
for lamp_mode
in LampMode],
35 getter=
lambda settings: settings.lamp_mode.name.lower(),
36 setter=
lambda client, option: client.set_lamp_mode(
37 LampMode[option.upper()].value
41 key=
"aroma_therapy_slot",
42 translation_key=
"aroma_therapy_slot",
44 aroma_therapy_slot.name.lower()
for aroma_therapy_slot
in AromaTherapySlot
46 getter=
lambda settings: settings.aroma_therapy_slot.name.lower(),
47 setter=
lambda client, option: client.set_aroma_therapy_slot(
48 AromaTherapySlot[option.upper()].value
57 async_add_entities: AddEntitiesCallback,
59 """Set up select entities for TOLO Sauna."""
60 coordinator = hass.data[DOMAIN][entry.entry_id]
67 """TOLO select entity."""
69 _attr_entity_category = EntityCategory.CONFIG
71 entity_description: ToloSelectEntityDescription
75 coordinator: ToloSaunaUpdateCoordinator,
77 entity_description: ToloSelectEntityDescription,
79 """Initialize TOLO select entity."""
82 self.
_attr_unique_id_attr_unique_id = f
"{entry.entry_id}_{entity_description.key}"
86 """Return available select options."""
91 """Return current select option."""
92 return self.
entity_descriptionentity_description.getter(self.coordinator.data.settings)
95 """Select a select option."""
None select_option(self, str option)
None __init__(self, ToloSaunaUpdateCoordinator coordinator, ConfigEntry entry, ToloSelectEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)