1 """Support for Aseko Pool Live sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
8 from aioaseko
import Unit
13 SensorEntityDescription,
21 from .coordinator
import AsekoConfigEntry
22 from .entity
import AsekoEntity
25 @dataclass(frozen=True, kw_only=True)
27 """Describes an Aseko sensor entity."""
29 value_fn: Callable[[Unit], StateType]
32 SENSORS: list[AsekoSensorEntityDescription] = [
35 translation_key=
"air_temperature",
36 device_class=SensorDeviceClass.TEMPERATURE,
37 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
38 state_class=SensorStateClass.MEASUREMENT,
39 value_fn=
lambda unit: unit.air_temperature,
43 translation_key=
"electrolyzer",
44 native_unit_of_measurement=
"g/h",
45 state_class=SensorStateClass.MEASUREMENT,
46 value_fn=
lambda unit: unit.electrolyzer,
50 translation_key=
"free_chlorine",
51 native_unit_of_measurement=
"mg/l",
52 state_class=SensorStateClass.MEASUREMENT,
53 value_fn=
lambda unit: unit.cl_free,
57 device_class=SensorDeviceClass.PH,
58 state_class=SensorStateClass.MEASUREMENT,
59 value_fn=
lambda unit: unit.ph,
63 translation_key=
"redox",
64 native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
65 state_class=SensorStateClass.MEASUREMENT,
66 value_fn=
lambda unit: unit.redox,
70 translation_key=
"salinity",
71 native_unit_of_measurement=
"kg/m³",
72 state_class=SensorStateClass.MEASUREMENT,
73 value_fn=
lambda unit: unit.salinity,
77 translation_key=
"water_temperature",
78 device_class=SensorDeviceClass.TEMPERATURE,
79 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
80 state_class=SensorStateClass.MEASUREMENT,
81 value_fn=
lambda unit: unit.water_temperature,
88 config_entry: AsekoConfigEntry,
89 async_add_entities: AddEntitiesCallback,
91 """Set up the Aseko Pool Live sensors."""
92 coordinator = config_entry.runtime_data
93 units = coordinator.data.values()
96 for description
in SENSORS
98 if description.value_fn(unit)
is not None
103 """Representation of an Aseko unit sensor entity."""
105 entity_description: AsekoSensorEntityDescription
109 """Return the state of the sensor."""
StateType native_value(self)
None async_setup_entry(HomeAssistant hass, AsekoConfigEntry config_entry, AddEntitiesCallback async_add_entities)