1 """TOLO Sauna (non-binary, general) sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from tololib
import ToloSettings, ToloStatus
13 SensorEntityDescription,
26 from .const
import DOMAIN
27 from .coordinator
import ToloSaunaUpdateCoordinator
28 from .entity
import ToloSaunaCoordinatorEntity
31 @dataclass(frozen=True, kw_only=True)
33 """Class describing TOLO Sensor entities."""
35 getter: Callable[[ToloStatus], int |
None]
36 availability_checker: Callable[[ToloSettings, ToloStatus], bool] |
None
38 state_class = SensorStateClass.MEASUREMENT
44 translation_key=
"water_level",
45 entity_category=EntityCategory.DIAGNOSTIC,
46 native_unit_of_measurement=PERCENTAGE,
47 getter=
lambda status: status.water_level_percent,
48 availability_checker=
None,
51 key=
"tank_temperature",
52 translation_key=
"tank_temperature",
53 device_class=SensorDeviceClass.TEMPERATURE,
54 entity_category=EntityCategory.DIAGNOSTIC,
55 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
56 getter=
lambda status: status.tank_temperature,
57 availability_checker=
None,
60 key=
"power_timer_remaining",
61 translation_key=
"power_timer_remaining",
62 entity_category=EntityCategory.DIAGNOSTIC,
63 native_unit_of_measurement=UnitOfTime.MINUTES,
64 getter=
lambda status: status.power_timer,
65 availability_checker=
lambda settings, status: status.power_on
66 and settings.power_timer
is not None,
69 key=
"salt_bath_timer_remaining",
70 translation_key=
"salt_bath_timer_remaining",
71 entity_category=EntityCategory.DIAGNOSTIC,
72 native_unit_of_measurement=UnitOfTime.MINUTES,
73 getter=
lambda status: status.salt_bath_timer,
74 availability_checker=
lambda settings, status: status.salt_bath_on
75 and settings.salt_bath_timer
is not None,
78 key=
"fan_timer_remaining",
79 translation_key=
"fan_timer_remaining",
80 entity_category=EntityCategory.DIAGNOSTIC,
81 native_unit_of_measurement=UnitOfTime.MINUTES,
82 getter=
lambda status: status.fan_timer,
83 availability_checker=
lambda settings, status: status.fan_on
84 and settings.fan_timer
is not None,
92 async_add_entities: AddEntitiesCallback,
94 """Set up (non-binary, general) sensors for TOLO Sauna."""
95 coordinator = hass.data[DOMAIN][entry.entry_id]
102 """TOLO Number entity."""
104 entity_description: ToloSensorEntityDescription
108 coordinator: ToloSaunaUpdateCoordinator,
110 entity_description: ToloSensorEntityDescription,
112 """Initialize TOLO Number entity."""
113 super().
__init__(coordinator, entry)
119 """Return availability of the TOLO sensor."""
121 return super().available
123 self.coordinator.data.settings, self.coordinator.data.status
128 """Return native value of the TOLO sensor."""
int|None native_value(self)
None __init__(self, ToloSaunaUpdateCoordinator coordinator, ConfigEntry entry, ToloSensorEntityDescription entity_description)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)