1 """Support for Vallox ventilation unit sensors."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
6 from datetime
import datetime, time
11 SensorEntityDescription,
16 CONCENTRATION_PARTS_PER_MILLION,
18 REVOLUTIONS_PER_MINUTE,
32 VALLOX_CELL_STATE_TO_STR,
33 VALLOX_PROFILE_TO_PRESET_MODE,
35 from .coordinator
import ValloxDataUpdateCoordinator
36 from .entity
import ValloxEntity
40 """Representation of a Vallox sensor."""
42 entity_description: ValloxSensorEntityDescription
43 _attr_entity_category = EntityCategory.DIAGNOSTIC
48 coordinator: ValloxDataUpdateCoordinator,
49 description: ValloxSensorEntityDescription,
51 """Initialize the Vallox sensor."""
60 """Return the value reported by the sensor."""
64 value = self.coordinator.data.get(metric_key)
75 """Child class for profile reporting."""
79 """Return the value reported by the sensor."""
80 vallox_profile = self.coordinator.data.profile
81 return VALLOX_PROFILE_TO_PRESET_MODE.get(vallox_profile)
91 """Child class for fan speed reporting."""
95 """Return the value reported by the sensor."""
96 fan_is_on = self.coordinator.data.get(METRIC_KEY_MODE) == MODE_ON
97 return super().native_value
if fan_is_on
else 0
101 """Child class for filter remaining time reporting."""
105 """Return the value reported by the sensor."""
106 next_filter_change_date = self.coordinator.data.next_filter_change_date
108 if next_filter_change_date
is None:
111 return datetime.combine(
112 next_filter_change_date,
113 time(hour=13, minute=0, second=0, tzinfo=dt_util.get_default_time_zone()),
118 """Child class for cell state reporting."""
122 """Return the value reported by the sensor."""
123 super_native_value = super().native_value
125 if not isinstance(super_native_value, int):
128 return VALLOX_CELL_STATE_TO_STR.get(super_native_value)
132 """Child class for profile duration reporting."""
136 """Return the value reported by the sensor."""
138 return self.coordinator.data.get_remaining_profile_duration(
139 self.coordinator.data.profile
143 @dataclass(frozen=True)
145 """Describes Vallox sensor entity."""
147 metric_key: str |
None =
None
148 entity_type: type[ValloxSensorEntity] = ValloxSensorEntity
149 round_ndigits: int |
None =
None
152 SENSOR_ENTITIES: tuple[ValloxSensorEntityDescription, ...] = (
154 key=
"current_profile",
155 translation_key=
"current_profile",
156 entity_type=ValloxProfileSensor,
160 translation_key=
"fan_speed",
161 metric_key=
"A_CYC_FAN_SPEED",
162 state_class=SensorStateClass.MEASUREMENT,
163 native_unit_of_measurement=PERCENTAGE,
164 entity_type=ValloxFanSpeedSensor,
167 key=
"extract_fan_speed",
168 translation_key=
"extract_fan_speed",
169 metric_key=
"A_CYC_EXTR_FAN_SPEED",
170 state_class=SensorStateClass.MEASUREMENT,
171 native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
172 entity_type=ValloxFanSpeedSensor,
173 entity_registry_enabled_default=
False,
176 key=
"supply_fan_speed",
177 translation_key=
"supply_fan_speed",
178 metric_key=
"A_CYC_SUPP_FAN_SPEED",
179 state_class=SensorStateClass.MEASUREMENT,
180 native_unit_of_measurement=REVOLUTIONS_PER_MINUTE,
181 entity_type=ValloxFanSpeedSensor,
182 entity_registry_enabled_default=
False,
185 key=
"remaining_time_for_filter",
186 translation_key=
"remaining_time_for_filter",
187 device_class=SensorDeviceClass.TIMESTAMP,
188 entity_type=ValloxFilterRemainingSensor,
192 translation_key=
"cell_state",
193 metric_key=
"A_CYC_CELL_STATE",
194 entity_type=ValloxCellStateSensor,
198 translation_key=
"extract_air",
199 metric_key=
"A_CYC_TEMP_EXTRACT_AIR",
200 device_class=SensorDeviceClass.TEMPERATURE,
201 state_class=SensorStateClass.MEASUREMENT,
202 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
206 translation_key=
"exhaust_air",
207 metric_key=
"A_CYC_TEMP_EXHAUST_AIR",
208 device_class=SensorDeviceClass.TEMPERATURE,
209 state_class=SensorStateClass.MEASUREMENT,
210 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
214 translation_key=
"outdoor_air",
215 metric_key=
"A_CYC_TEMP_OUTDOOR_AIR",
216 device_class=SensorDeviceClass.TEMPERATURE,
217 state_class=SensorStateClass.MEASUREMENT,
218 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
222 translation_key=
"supply_air",
223 metric_key=
"A_CYC_TEMP_SUPPLY_AIR",
224 device_class=SensorDeviceClass.TEMPERATURE,
225 state_class=SensorStateClass.MEASUREMENT,
226 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
229 key=
"supply_cell_air",
230 translation_key=
"supply_cell_air",
231 metric_key=
"A_CYC_TEMP_SUPPLY_CELL_AIR",
232 device_class=SensorDeviceClass.TEMPERATURE,
233 state_class=SensorStateClass.MEASUREMENT,
234 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
238 translation_key=
"optional_air",
239 metric_key=
"A_CYC_TEMP_OPTIONAL",
240 device_class=SensorDeviceClass.TEMPERATURE,
241 state_class=SensorStateClass.MEASUREMENT,
242 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
243 entity_registry_enabled_default=
False,
247 metric_key=
"A_CYC_RH_VALUE",
248 device_class=SensorDeviceClass.HUMIDITY,
249 state_class=SensorStateClass.MEASUREMENT,
250 native_unit_of_measurement=PERCENTAGE,
254 translation_key=
"efficiency",
255 metric_key=
"A_CYC_EXTRACT_EFFICIENCY",
256 state_class=SensorStateClass.MEASUREMENT,
257 native_unit_of_measurement=PERCENTAGE,
258 entity_registry_enabled_default=
False,
263 metric_key=
"A_CYC_CO2_VALUE",
264 device_class=SensorDeviceClass.CO2,
265 state_class=SensorStateClass.MEASUREMENT,
266 native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
267 entity_registry_enabled_default=
False,
270 key=
"profile_duration",
271 translation_key=
"profile_duration",
272 device_class=SensorDeviceClass.DURATION,
273 state_class=SensorStateClass.MEASUREMENT,
274 native_unit_of_measurement=UnitOfTime.MINUTES,
275 entity_type=ValloxProfileDurationSensor,
281 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
283 """Set up the sensors."""
284 name = hass.data[DOMAIN][entry.entry_id][
"name"]
285 coordinator = hass.data[DOMAIN][entry.entry_id][
"coordinator"]
288 description.entity_type(name, coordinator, description)
289 for description
in SENSOR_ENTITIES
StateType native_value(self)
StateType|datetime native_value(self)
StateType|datetime native_value(self)
StateType native_value(self)
StateType native_value(self)
None __init__(self, str name, ValloxDataUpdateCoordinator coordinator, ValloxSensorEntityDescription description)
StateType|datetime native_value(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
bool time(HomeAssistant hass, dt_time|str|None before=None, dt_time|str|None after=None, str|Container[str]|None weekday=None)