1 """Plugwise Sensor component for Home Assistant."""
3 from __future__
import annotations
5 from dataclasses
import dataclass
7 from plugwise.constants
import SensorType
12 SensorEntityDescription,
19 UnitOfElectricPotential,
30 from .
import PlugwiseConfigEntry
31 from .coordinator
import PlugwiseDataUpdateCoordinator
32 from .entity
import PlugwiseEntity
35 @dataclass(frozen=True)
37 """Describes Plugwise sensor entity."""
42 SENSORS: tuple[PlugwiseSensorEntityDescription, ...] = (
45 translation_key=
"setpoint",
46 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
47 device_class=SensorDeviceClass.TEMPERATURE,
48 state_class=SensorStateClass.MEASUREMENT,
49 entity_category=EntityCategory.DIAGNOSTIC,
53 translation_key=
"cooling_setpoint",
54 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
55 device_class=SensorDeviceClass.TEMPERATURE,
56 state_class=SensorStateClass.MEASUREMENT,
57 entity_category=EntityCategory.DIAGNOSTIC,
61 translation_key=
"heating_setpoint",
62 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
63 device_class=SensorDeviceClass.TEMPERATURE,
64 state_class=SensorStateClass.MEASUREMENT,
65 entity_category=EntityCategory.DIAGNOSTIC,
69 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
70 device_class=SensorDeviceClass.TEMPERATURE,
71 entity_category=EntityCategory.DIAGNOSTIC,
72 state_class=SensorStateClass.MEASUREMENT,
75 key=
"intended_boiler_temperature",
76 translation_key=
"intended_boiler_temperature",
77 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
78 device_class=SensorDeviceClass.TEMPERATURE,
79 entity_category=EntityCategory.DIAGNOSTIC,
80 state_class=SensorStateClass.MEASUREMENT,
83 key=
"temperature_difference",
84 translation_key=
"temperature_difference",
85 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
86 device_class=SensorDeviceClass.TEMPERATURE,
87 entity_category=EntityCategory.DIAGNOSTIC,
88 state_class=SensorStateClass.MEASUREMENT,
91 key=
"outdoor_temperature",
92 translation_key=
"outdoor_temperature",
93 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
94 device_class=SensorDeviceClass.TEMPERATURE,
95 state_class=SensorStateClass.MEASUREMENT,
98 key=
"outdoor_air_temperature",
99 translation_key=
"outdoor_air_temperature",
100 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
101 device_class=SensorDeviceClass.TEMPERATURE,
102 entity_category=EntityCategory.DIAGNOSTIC,
103 state_class=SensorStateClass.MEASUREMENT,
106 key=
"water_temperature",
107 translation_key=
"water_temperature",
108 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
109 device_class=SensorDeviceClass.TEMPERATURE,
110 entity_category=EntityCategory.DIAGNOSTIC,
111 state_class=SensorStateClass.MEASUREMENT,
114 key=
"return_temperature",
115 translation_key=
"return_temperature",
116 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
117 device_class=SensorDeviceClass.TEMPERATURE,
118 entity_category=EntityCategory.DIAGNOSTIC,
119 state_class=SensorStateClass.MEASUREMENT,
122 key=
"electricity_consumed",
123 translation_key=
"electricity_consumed",
124 native_unit_of_measurement=UnitOfPower.WATT,
125 device_class=SensorDeviceClass.POWER,
126 state_class=SensorStateClass.MEASUREMENT,
129 key=
"electricity_produced",
130 translation_key=
"electricity_produced",
131 native_unit_of_measurement=UnitOfPower.WATT,
132 device_class=SensorDeviceClass.POWER,
133 state_class=SensorStateClass.MEASUREMENT,
134 entity_registry_enabled_default=
False,
137 key=
"electricity_consumed_interval",
138 translation_key=
"electricity_consumed_interval",
139 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
140 device_class=SensorDeviceClass.ENERGY,
141 state_class=SensorStateClass.TOTAL,
144 key=
"electricity_consumed_peak_interval",
145 translation_key=
"electricity_consumed_peak_interval",
146 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
147 device_class=SensorDeviceClass.ENERGY,
148 state_class=SensorStateClass.TOTAL,
151 key=
"electricity_consumed_off_peak_interval",
152 translation_key=
"electricity_consumed_off_peak_interval",
153 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
154 device_class=SensorDeviceClass.ENERGY,
155 state_class=SensorStateClass.TOTAL,
158 key=
"electricity_produced_interval",
159 translation_key=
"electricity_produced_interval",
160 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
161 device_class=SensorDeviceClass.ENERGY,
162 state_class=SensorStateClass.TOTAL,
163 entity_registry_enabled_default=
False,
166 key=
"electricity_produced_peak_interval",
167 translation_key=
"electricity_produced_peak_interval",
168 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
169 device_class=SensorDeviceClass.ENERGY,
170 state_class=SensorStateClass.TOTAL,
173 key=
"electricity_produced_off_peak_interval",
174 translation_key=
"electricity_produced_off_peak_interval",
175 native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
176 device_class=SensorDeviceClass.ENERGY,
177 state_class=SensorStateClass.TOTAL,
180 key=
"electricity_consumed_point",
181 translation_key=
"electricity_consumed_point",
182 device_class=SensorDeviceClass.POWER,
183 native_unit_of_measurement=UnitOfPower.WATT,
184 state_class=SensorStateClass.MEASUREMENT,
187 key=
"electricity_consumed_off_peak_point",
188 translation_key=
"electricity_consumed_off_peak_point",
189 native_unit_of_measurement=UnitOfPower.WATT,
190 device_class=SensorDeviceClass.POWER,
191 state_class=SensorStateClass.MEASUREMENT,
194 key=
"electricity_consumed_peak_point",
195 translation_key=
"electricity_consumed_peak_point",
196 native_unit_of_measurement=UnitOfPower.WATT,
197 device_class=SensorDeviceClass.POWER,
198 state_class=SensorStateClass.MEASUREMENT,
201 key=
"electricity_consumed_off_peak_cumulative",
202 translation_key=
"electricity_consumed_off_peak_cumulative",
203 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
204 device_class=SensorDeviceClass.ENERGY,
205 state_class=SensorStateClass.TOTAL_INCREASING,
208 key=
"electricity_consumed_peak_cumulative",
209 translation_key=
"electricity_consumed_peak_cumulative",
210 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
211 device_class=SensorDeviceClass.ENERGY,
212 state_class=SensorStateClass.TOTAL_INCREASING,
215 key=
"electricity_produced_point",
216 translation_key=
"electricity_produced_point",
217 device_class=SensorDeviceClass.POWER,
218 native_unit_of_measurement=UnitOfPower.WATT,
219 state_class=SensorStateClass.MEASUREMENT,
222 key=
"electricity_produced_off_peak_point",
223 translation_key=
"electricity_produced_off_peak_point",
224 native_unit_of_measurement=UnitOfPower.WATT,
225 device_class=SensorDeviceClass.POWER,
226 state_class=SensorStateClass.MEASUREMENT,
229 key=
"electricity_produced_peak_point",
230 translation_key=
"electricity_produced_peak_point",
231 native_unit_of_measurement=UnitOfPower.WATT,
232 device_class=SensorDeviceClass.POWER,
233 state_class=SensorStateClass.MEASUREMENT,
236 key=
"electricity_produced_off_peak_cumulative",
237 translation_key=
"electricity_produced_off_peak_cumulative",
238 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
239 device_class=SensorDeviceClass.ENERGY,
240 state_class=SensorStateClass.TOTAL_INCREASING,
243 key=
"electricity_produced_peak_cumulative",
244 translation_key=
"electricity_produced_peak_cumulative",
245 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
246 device_class=SensorDeviceClass.ENERGY,
247 state_class=SensorStateClass.TOTAL_INCREASING,
250 key=
"electricity_phase_one_consumed",
251 translation_key=
"electricity_phase_one_consumed",
252 device_class=SensorDeviceClass.POWER,
253 native_unit_of_measurement=UnitOfPower.WATT,
254 state_class=SensorStateClass.MEASUREMENT,
257 key=
"electricity_phase_two_consumed",
258 translation_key=
"electricity_phase_two_consumed",
259 device_class=SensorDeviceClass.POWER,
260 native_unit_of_measurement=UnitOfPower.WATT,
261 state_class=SensorStateClass.MEASUREMENT,
264 key=
"electricity_phase_three_consumed",
265 translation_key=
"electricity_phase_three_consumed",
266 device_class=SensorDeviceClass.POWER,
267 native_unit_of_measurement=UnitOfPower.WATT,
268 state_class=SensorStateClass.MEASUREMENT,
271 key=
"electricity_phase_one_produced",
272 translation_key=
"electricity_phase_one_produced",
273 device_class=SensorDeviceClass.POWER,
274 native_unit_of_measurement=UnitOfPower.WATT,
275 state_class=SensorStateClass.MEASUREMENT,
278 key=
"electricity_phase_two_produced",
279 translation_key=
"electricity_phase_two_produced",
280 device_class=SensorDeviceClass.POWER,
281 native_unit_of_measurement=UnitOfPower.WATT,
282 state_class=SensorStateClass.MEASUREMENT,
285 key=
"electricity_phase_three_produced",
286 translation_key=
"electricity_phase_three_produced",
287 device_class=SensorDeviceClass.POWER,
288 native_unit_of_measurement=UnitOfPower.WATT,
289 state_class=SensorStateClass.MEASUREMENT,
292 key=
"voltage_phase_one",
293 translation_key=
"voltage_phase_one",
294 device_class=SensorDeviceClass.VOLTAGE,
295 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
296 state_class=SensorStateClass.MEASUREMENT,
297 entity_registry_enabled_default=
False,
300 key=
"voltage_phase_two",
301 translation_key=
"voltage_phase_two",
302 device_class=SensorDeviceClass.VOLTAGE,
303 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
304 state_class=SensorStateClass.MEASUREMENT,
305 entity_registry_enabled_default=
False,
308 key=
"voltage_phase_three",
309 translation_key=
"voltage_phase_three",
310 device_class=SensorDeviceClass.VOLTAGE,
311 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
312 state_class=SensorStateClass.MEASUREMENT,
313 entity_registry_enabled_default=
False,
316 key=
"gas_consumed_interval",
317 translation_key=
"gas_consumed_interval",
318 native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
319 state_class=SensorStateClass.MEASUREMENT,
322 key=
"gas_consumed_cumulative",
323 translation_key=
"gas_consumed_cumulative",
324 native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
325 device_class=SensorDeviceClass.GAS,
326 state_class=SensorStateClass.TOTAL,
329 key=
"net_electricity_point",
330 translation_key=
"net_electricity_point",
331 native_unit_of_measurement=UnitOfPower.WATT,
332 device_class=SensorDeviceClass.POWER,
333 state_class=SensorStateClass.MEASUREMENT,
336 key=
"net_electricity_cumulative",
337 translation_key=
"net_electricity_cumulative",
338 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
339 device_class=SensorDeviceClass.ENERGY,
340 state_class=SensorStateClass.TOTAL,
344 native_unit_of_measurement=PERCENTAGE,
345 device_class=SensorDeviceClass.BATTERY,
346 entity_category=EntityCategory.DIAGNOSTIC,
347 state_class=SensorStateClass.MEASUREMENT,
351 native_unit_of_measurement=LIGHT_LUX,
352 device_class=SensorDeviceClass.ILLUMINANCE,
353 state_class=SensorStateClass.MEASUREMENT,
354 entity_category=EntityCategory.DIAGNOSTIC,
357 key=
"modulation_level",
358 translation_key=
"modulation_level",
359 native_unit_of_measurement=PERCENTAGE,
360 entity_category=EntityCategory.DIAGNOSTIC,
361 state_class=SensorStateClass.MEASUREMENT,
364 key=
"valve_position",
365 translation_key=
"valve_position",
366 entity_category=EntityCategory.DIAGNOSTIC,
367 native_unit_of_measurement=PERCENTAGE,
368 state_class=SensorStateClass.MEASUREMENT,
371 key=
"water_pressure",
372 translation_key=
"water_pressure",
373 native_unit_of_measurement=UnitOfPressure.BAR,
374 device_class=SensorDeviceClass.PRESSURE,
375 entity_category=EntityCategory.DIAGNOSTIC,
376 state_class=SensorStateClass.MEASUREMENT,
380 native_unit_of_measurement=PERCENTAGE,
381 device_class=SensorDeviceClass.HUMIDITY,
382 state_class=SensorStateClass.MEASUREMENT,
385 key=
"dhw_temperature",
386 translation_key=
"dhw_temperature",
387 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
388 device_class=SensorDeviceClass.TEMPERATURE,
389 entity_category=EntityCategory.DIAGNOSTIC,
390 state_class=SensorStateClass.MEASUREMENT,
393 key=
"domestic_hot_water_setpoint",
394 translation_key=
"domestic_hot_water_setpoint",
395 native_unit_of_measurement=UnitOfTemperature.CELSIUS,
396 device_class=SensorDeviceClass.TEMPERATURE,
397 entity_category=EntityCategory.DIAGNOSTIC,
398 state_class=SensorStateClass.MEASUREMENT,
405 entry: PlugwiseConfigEntry,
406 async_add_entities: AddEntitiesCallback,
408 """Set up the Smile sensors from a config entry."""
409 coordinator = entry.runtime_data
412 def _add_entities() -> None:
414 if not coordinator.new_devices:
419 for device_id
in coordinator.new_devices
420 if (sensors := coordinator.data.devices[device_id].
get(
"sensors"))
421 for description
in SENSORS
422 if description.key
in sensors
426 entry.async_on_unload(coordinator.async_add_listener(_add_entities))
430 """Represent Plugwise Sensors."""
432 entity_description: PlugwiseSensorEntityDescription
436 coordinator: PlugwiseDataUpdateCoordinator,
438 description: PlugwiseSensorEntityDescription,
440 """Initialise the sensor."""
441 super().
__init__(coordinator, device_id)
447 """Return the value reported by the sensor."""
GwEntityData device(self)
None __init__(self, PlugwiseDataUpdateCoordinator coordinator, str device_id, PlugwiseSensorEntityDescription description)
int|float native_value(self)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, PlugwiseConfigEntry entry, AddEntitiesCallback async_add_entities)