1 """TOLO Sauna number controls."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
23 from .const
import DOMAIN
24 from .coordinator
import ToloSaunaUpdateCoordinator
25 from .entity
import ToloSaunaCoordinatorEntity
28 @dataclass(frozen=True, kw_only=True)
30 """Class describing TOLO Number entities."""
32 getter: Callable[[ToloSettings], int |
None]
33 setter: Callable[[ToloClient, int |
None], Any]
35 entity_category = EntityCategory.CONFIG
43 translation_key=
"power_timer",
44 native_unit_of_measurement=UnitOfTime.MINUTES,
45 native_max_value=POWER_TIMER_MAX,
46 getter=
lambda settings: settings.power_timer,
47 setter=
lambda client, value: client.set_power_timer(value),
50 key=
"salt_bath_timer",
51 translation_key=
"salt_bath_timer",
52 native_unit_of_measurement=UnitOfTime.MINUTES,
53 native_max_value=SALT_BATH_TIMER_MAX,
54 getter=
lambda settings: settings.salt_bath_timer,
55 setter=
lambda client, value: client.set_salt_bath_timer(value),
59 translation_key=
"fan_timer",
60 native_unit_of_measurement=UnitOfTime.MINUTES,
61 native_max_value=FAN_TIMER_MAX,
62 getter=
lambda settings: settings.fan_timer,
63 setter=
lambda client, value: client.set_fan_timer(value),
71 async_add_entities: AddEntitiesCallback,
73 """Set up number controls for TOLO Sauna."""
74 coordinator = hass.data[DOMAIN][entry.entry_id]
81 """TOLO Number entity."""
83 entity_description: ToloNumberEntityDescription
87 coordinator: ToloSaunaUpdateCoordinator,
89 entity_description: ToloNumberEntityDescription,
91 """Initialize TOLO Number entity."""
94 self.
_attr_unique_id_attr_unique_id = f
"{entry.entry_id}_{entity_description.key}"
98 """Return the value of this TOLO Number entity."""
99 return self.
entity_descriptionentity_description.getter(self.coordinator.data.settings)
or 0
102 """Set the value of this TOLO Number entity."""
103 int_value =
int(value)
None set_native_value(self, float value)
None __init__(self, ToloSaunaUpdateCoordinator coordinator, ConfigEntry entry, ToloNumberEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)