1 """Support for Epion API."""
3 from __future__
import annotations
10 SensorEntityDescription,
15 CONCENTRATION_PARTS_PER_MILLION,
25 from .const
import DOMAIN
26 from .coordinator
import EpionCoordinator
28 SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
30 device_class=SensorDeviceClass.CO2,
31 state_class=SensorStateClass.MEASUREMENT,
32 native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
34 suggested_display_precision=0,
37 device_class=SensorDeviceClass.TEMPERATURE,
38 state_class=SensorStateClass.MEASUREMENT,
39 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
41 suggested_display_precision=1,
44 device_class=SensorDeviceClass.HUMIDITY,
45 state_class=SensorStateClass.MEASUREMENT,
46 native_unit_of_measurement=PERCENTAGE,
48 suggested_display_precision=1,
51 device_class=SensorDeviceClass.ATMOSPHERIC_PRESSURE,
52 state_class=SensorStateClass.MEASUREMENT,
53 native_unit_of_measurement=UnitOfPressure.HPA,
55 suggested_display_precision=0,
63 async_add_entities: AddEntitiesCallback,
65 """Add an Epion entry."""
66 coordinator: EpionCoordinator = hass.data[DOMAIN][entry.entry_id]
69 EpionSensor(coordinator, epion_device_id, description)
70 for epion_device_id
in coordinator.data
71 for description
in SENSOR_TYPES
78 """Representation of an Epion Air sensor."""
80 _attr_has_entity_name =
True
84 coordinator: EpionCoordinator,
86 description: SensorEntityDescription,
88 """Initialize an EpionSensor."""
94 identifiers={(DOMAIN, epion_device_id)},
97 sw_version=self.
devicedevice.
get(
"fwVersion"),
103 """Return the value reported by the sensor, or None if the relevant sensor can't produce a current measurement."""
108 """Return the availability of the device that provides this sensor data."""
109 return super().available
and self.
_epion_device_id_epion_device_id
in self.coordinator.data
113 """Get the device record from the current coordinator data, or None if there is no data being returned for this device ID anymore."""
None __init__(self, EpionCoordinator coordinator, str epion_device_id, SensorEntityDescription description)
dict[str, Any] device(self)
float|None native_value(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)