1 """Platform for Kostal Plenticore sensors."""
3 from __future__
import annotations
5 from collections.abc
import Callable
6 from dataclasses
import dataclass
7 from datetime
import timedelta
14 SensorEntityDescription,
21 UnitOfElectricCurrent,
22 UnitOfElectricPotential,
32 from .const
import DOMAIN
33 from .coordinator
import ProcessDataUpdateCoordinator
34 from .helper
import PlenticoreDataFormatter
36 _LOGGER = logging.getLogger(__name__)
39 @dataclass(frozen=True, kw_only=True)
41 """A class that describes plenticore sensor entities."""
47 SENSOR_PROCESS_DATA = [
49 module_id=
"devices:local",
51 name=
"Inverter State",
52 icon=
"mdi:state-machine",
53 formatter=
"format_inverter_state",
56 module_id=
"devices:local",
59 native_unit_of_measurement=UnitOfPower.WATT,
60 device_class=SensorDeviceClass.POWER,
61 entity_registry_enabled_default=
True,
62 state_class=SensorStateClass.MEASUREMENT,
63 formatter=
"format_round",
66 module_id=
"devices:local",
69 native_unit_of_measurement=UnitOfPower.WATT,
70 device_class=SensorDeviceClass.POWER,
71 entity_registry_enabled_default=
True,
72 state_class=SensorStateClass.MEASUREMENT,
73 formatter=
"format_round",
76 module_id=
"devices:local",
78 name=
"Home Power from Battery",
79 native_unit_of_measurement=UnitOfPower.WATT,
80 device_class=SensorDeviceClass.POWER,
81 state_class=SensorStateClass.MEASUREMENT,
82 formatter=
"format_round",
85 module_id=
"devices:local",
87 name=
"Home Power from Grid",
88 native_unit_of_measurement=UnitOfPower.WATT,
89 device_class=SensorDeviceClass.POWER,
90 state_class=SensorStateClass.MEASUREMENT,
91 formatter=
"format_round",
94 module_id=
"devices:local",
96 name=
"Home Power from Own",
97 native_unit_of_measurement=UnitOfPower.WATT,
98 device_class=SensorDeviceClass.POWER,
99 state_class=SensorStateClass.MEASUREMENT,
100 formatter=
"format_round",
103 module_id=
"devices:local",
105 name=
"Home Power from PV",
106 native_unit_of_measurement=UnitOfPower.WATT,
107 device_class=SensorDeviceClass.POWER,
108 state_class=SensorStateClass.MEASUREMENT,
109 formatter=
"format_round",
112 module_id=
"devices:local",
115 native_unit_of_measurement=UnitOfPower.WATT,
116 device_class=SensorDeviceClass.POWER,
117 state_class=SensorStateClass.MEASUREMENT,
118 formatter=
"format_round",
121 module_id=
"devices:local:ac",
124 native_unit_of_measurement=UnitOfPower.WATT,
125 device_class=SensorDeviceClass.POWER,
126 entity_registry_enabled_default=
True,
127 state_class=SensorStateClass.MEASUREMENT,
128 formatter=
"format_round",
131 module_id=
"devices:local:pv1",
134 native_unit_of_measurement=UnitOfPower.WATT,
135 device_class=SensorDeviceClass.POWER,
136 state_class=SensorStateClass.MEASUREMENT,
137 formatter=
"format_round",
140 module_id=
"devices:local:pv1",
143 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
144 device_class=SensorDeviceClass.VOLTAGE,
145 state_class=SensorStateClass.MEASUREMENT,
146 formatter=
"format_round",
149 module_id=
"devices:local:pv1",
152 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
153 device_class=SensorDeviceClass.CURRENT,
154 state_class=SensorStateClass.MEASUREMENT,
155 formatter=
"format_float",
158 module_id=
"devices:local:pv2",
161 native_unit_of_measurement=UnitOfPower.WATT,
162 device_class=SensorDeviceClass.POWER,
163 state_class=SensorStateClass.MEASUREMENT,
164 formatter=
"format_round",
167 module_id=
"devices:local:pv2",
170 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
171 device_class=SensorDeviceClass.VOLTAGE,
172 state_class=SensorStateClass.MEASUREMENT,
173 formatter=
"format_round",
176 module_id=
"devices:local:pv2",
179 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
180 device_class=SensorDeviceClass.CURRENT,
181 state_class=SensorStateClass.MEASUREMENT,
182 formatter=
"format_float",
185 module_id=
"devices:local:pv3",
188 native_unit_of_measurement=UnitOfPower.WATT,
189 device_class=SensorDeviceClass.POWER,
190 state_class=SensorStateClass.MEASUREMENT,
191 formatter=
"format_round",
194 module_id=
"devices:local:pv3",
197 native_unit_of_measurement=UnitOfElectricPotential.VOLT,
198 device_class=SensorDeviceClass.VOLTAGE,
199 state_class=SensorStateClass.MEASUREMENT,
200 formatter=
"format_round",
203 module_id=
"devices:local:pv3",
206 native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
207 device_class=SensorDeviceClass.CURRENT,
208 state_class=SensorStateClass.MEASUREMENT,
209 formatter=
"format_float",
212 module_id=
"devices:local",
214 name=
"PV to Battery Power",
215 native_unit_of_measurement=UnitOfPower.WATT,
216 device_class=SensorDeviceClass.POWER,
217 state_class=SensorStateClass.MEASUREMENT,
218 formatter=
"format_round",
221 module_id=
"devices:local",
223 name=
"Energy Manager State",
224 icon=
"mdi:state-machine",
225 formatter=
"format_em_manager_state",
228 module_id=
"devices:local:battery",
230 name=
"Battery Cycles",
232 state_class=SensorStateClass.TOTAL_INCREASING,
233 formatter=
"format_round",
236 module_id=
"devices:local:battery",
238 name=
"Battery Power",
239 native_unit_of_measurement=UnitOfPower.WATT,
240 device_class=SensorDeviceClass.POWER,
241 state_class=SensorStateClass.MEASUREMENT,
242 formatter=
"format_round",
245 module_id=
"devices:local:battery",
248 native_unit_of_measurement=PERCENTAGE,
249 device_class=SensorDeviceClass.BATTERY,
250 formatter=
"format_round",
253 module_id=
"scb:statistic:EnergyFlow",
254 key=
"Statistic:Autarky:Day",
256 native_unit_of_measurement=PERCENTAGE,
257 icon=
"mdi:chart-donut",
258 formatter=
"format_round",
261 module_id=
"scb:statistic:EnergyFlow",
262 key=
"Statistic:Autarky:Month",
263 name=
"Autarky Month",
264 native_unit_of_measurement=PERCENTAGE,
265 icon=
"mdi:chart-donut",
266 formatter=
"format_round",
269 module_id=
"scb:statistic:EnergyFlow",
270 key=
"Statistic:Autarky:Total",
271 name=
"Autarky Total",
272 native_unit_of_measurement=PERCENTAGE,
273 icon=
"mdi:chart-donut",
274 state_class=SensorStateClass.MEASUREMENT,
275 formatter=
"format_round",
278 module_id=
"scb:statistic:EnergyFlow",
279 key=
"Statistic:Autarky:Year",
281 native_unit_of_measurement=PERCENTAGE,
282 icon=
"mdi:chart-donut",
283 formatter=
"format_round",
286 module_id=
"scb:statistic:EnergyFlow",
287 key=
"Statistic:OwnConsumptionRate:Day",
288 name=
"Own Consumption Rate Day",
289 native_unit_of_measurement=PERCENTAGE,
290 icon=
"mdi:chart-donut",
291 formatter=
"format_round",
294 module_id=
"scb:statistic:EnergyFlow",
295 key=
"Statistic:OwnConsumptionRate:Month",
296 name=
"Own Consumption Rate Month",
297 native_unit_of_measurement=PERCENTAGE,
298 icon=
"mdi:chart-donut",
299 formatter=
"format_round",
302 module_id=
"scb:statistic:EnergyFlow",
303 key=
"Statistic:OwnConsumptionRate:Total",
304 name=
"Own Consumption Rate Total",
305 native_unit_of_measurement=PERCENTAGE,
306 icon=
"mdi:chart-donut",
307 state_class=SensorStateClass.MEASUREMENT,
308 formatter=
"format_round",
311 module_id=
"scb:statistic:EnergyFlow",
312 key=
"Statistic:OwnConsumptionRate:Year",
313 name=
"Own Consumption Rate Year",
314 native_unit_of_measurement=PERCENTAGE,
315 icon=
"mdi:chart-donut",
316 formatter=
"format_round",
319 module_id=
"scb:statistic:EnergyFlow",
320 key=
"Statistic:EnergyHome:Day",
321 name=
"Home Consumption Day",
322 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
323 device_class=SensorDeviceClass.ENERGY,
324 state_class=SensorStateClass.TOTAL_INCREASING,
325 formatter=
"format_energy",
328 module_id=
"scb:statistic:EnergyFlow",
329 key=
"Statistic:EnergyHome:Month",
330 name=
"Home Consumption Month",
331 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
332 device_class=SensorDeviceClass.ENERGY,
333 state_class=SensorStateClass.TOTAL_INCREASING,
334 formatter=
"format_energy",
337 module_id=
"scb:statistic:EnergyFlow",
338 key=
"Statistic:EnergyHome:Year",
339 name=
"Home Consumption Year",
340 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
341 device_class=SensorDeviceClass.ENERGY,
342 state_class=SensorStateClass.TOTAL_INCREASING,
343 formatter=
"format_energy",
346 module_id=
"scb:statistic:EnergyFlow",
347 key=
"Statistic:EnergyHome:Total",
348 name=
"Home Consumption Total",
349 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
350 device_class=SensorDeviceClass.ENERGY,
351 state_class=SensorStateClass.TOTAL_INCREASING,
352 formatter=
"format_energy",
355 module_id=
"scb:statistic:EnergyFlow",
356 key=
"Statistic:EnergyHomeBat:Day",
357 name=
"Home Consumption from Battery Day",
358 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
359 device_class=SensorDeviceClass.ENERGY,
360 state_class=SensorStateClass.TOTAL_INCREASING,
361 formatter=
"format_energy",
364 module_id=
"scb:statistic:EnergyFlow",
365 key=
"Statistic:EnergyHomeBat:Month",
366 name=
"Home Consumption from Battery Month",
367 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
368 device_class=SensorDeviceClass.ENERGY,
369 state_class=SensorStateClass.TOTAL_INCREASING,
370 formatter=
"format_energy",
373 module_id=
"scb:statistic:EnergyFlow",
374 key=
"Statistic:EnergyHomeBat:Year",
375 name=
"Home Consumption from Battery Year",
376 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
377 device_class=SensorDeviceClass.ENERGY,
378 state_class=SensorStateClass.TOTAL_INCREASING,
379 formatter=
"format_energy",
382 module_id=
"scb:statistic:EnergyFlow",
383 key=
"Statistic:EnergyHomeBat:Total",
384 name=
"Home Consumption from Battery Total",
385 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
386 device_class=SensorDeviceClass.ENERGY,
387 state_class=SensorStateClass.TOTAL_INCREASING,
388 formatter=
"format_energy",
391 module_id=
"scb:statistic:EnergyFlow",
392 key=
"Statistic:EnergyHomeGrid:Day",
393 name=
"Home Consumption from Grid Day",
394 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
395 device_class=SensorDeviceClass.ENERGY,
396 state_class=SensorStateClass.TOTAL_INCREASING,
397 formatter=
"format_energy",
400 module_id=
"scb:statistic:EnergyFlow",
401 key=
"Statistic:EnergyHomeGrid:Month",
402 name=
"Home Consumption from Grid Month",
403 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
404 device_class=SensorDeviceClass.ENERGY,
405 state_class=SensorStateClass.TOTAL_INCREASING,
406 formatter=
"format_energy",
409 module_id=
"scb:statistic:EnergyFlow",
410 key=
"Statistic:EnergyHomeGrid:Year",
411 name=
"Home Consumption from Grid Year",
412 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
413 device_class=SensorDeviceClass.ENERGY,
414 state_class=SensorStateClass.TOTAL_INCREASING,
415 formatter=
"format_energy",
418 module_id=
"scb:statistic:EnergyFlow",
419 key=
"Statistic:EnergyHomeGrid:Total",
420 name=
"Home Consumption from Grid Total",
421 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
422 device_class=SensorDeviceClass.ENERGY,
423 state_class=SensorStateClass.TOTAL_INCREASING,
424 formatter=
"format_energy",
427 module_id=
"scb:statistic:EnergyFlow",
428 key=
"Statistic:EnergyHomePv:Day",
429 name=
"Home Consumption from PV Day",
430 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
431 device_class=SensorDeviceClass.ENERGY,
432 state_class=SensorStateClass.TOTAL_INCREASING,
433 formatter=
"format_energy",
436 module_id=
"scb:statistic:EnergyFlow",
437 key=
"Statistic:EnergyHomePv:Month",
438 name=
"Home Consumption from PV Month",
439 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
440 device_class=SensorDeviceClass.ENERGY,
441 state_class=SensorStateClass.TOTAL_INCREASING,
442 formatter=
"format_energy",
445 module_id=
"scb:statistic:EnergyFlow",
446 key=
"Statistic:EnergyHomePv:Year",
447 name=
"Home Consumption from PV Year",
448 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
449 device_class=SensorDeviceClass.ENERGY,
450 state_class=SensorStateClass.TOTAL_INCREASING,
451 formatter=
"format_energy",
454 module_id=
"scb:statistic:EnergyFlow",
455 key=
"Statistic:EnergyHomePv:Total",
456 name=
"Home Consumption from PV Total",
457 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
458 device_class=SensorDeviceClass.ENERGY,
459 state_class=SensorStateClass.TOTAL_INCREASING,
460 formatter=
"format_energy",
463 module_id=
"scb:statistic:EnergyFlow",
464 key=
"Statistic:EnergyPv1:Day",
465 name=
"Energy PV1 Day",
466 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
467 device_class=SensorDeviceClass.ENERGY,
468 state_class=SensorStateClass.TOTAL_INCREASING,
469 formatter=
"format_energy",
472 module_id=
"scb:statistic:EnergyFlow",
473 key=
"Statistic:EnergyPv1:Month",
474 name=
"Energy PV1 Month",
475 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
476 device_class=SensorDeviceClass.ENERGY,
477 state_class=SensorStateClass.TOTAL_INCREASING,
478 formatter=
"format_energy",
481 module_id=
"scb:statistic:EnergyFlow",
482 key=
"Statistic:EnergyPv1:Year",
483 name=
"Energy PV1 Year",
484 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
485 device_class=SensorDeviceClass.ENERGY,
486 state_class=SensorStateClass.TOTAL_INCREASING,
487 formatter=
"format_energy",
490 module_id=
"scb:statistic:EnergyFlow",
491 key=
"Statistic:EnergyPv1:Total",
492 name=
"Energy PV1 Total",
493 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
494 device_class=SensorDeviceClass.ENERGY,
495 state_class=SensorStateClass.TOTAL_INCREASING,
496 formatter=
"format_energy",
499 module_id=
"scb:statistic:EnergyFlow",
500 key=
"Statistic:EnergyPv2:Day",
501 name=
"Energy PV2 Day",
502 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
503 device_class=SensorDeviceClass.ENERGY,
504 state_class=SensorStateClass.TOTAL_INCREASING,
505 formatter=
"format_energy",
508 module_id=
"scb:statistic:EnergyFlow",
509 key=
"Statistic:EnergyPv2:Month",
510 name=
"Energy PV2 Month",
511 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
512 device_class=SensorDeviceClass.ENERGY,
513 state_class=SensorStateClass.TOTAL_INCREASING,
514 formatter=
"format_energy",
517 module_id=
"scb:statistic:EnergyFlow",
518 key=
"Statistic:EnergyPv2:Year",
519 name=
"Energy PV2 Year",
520 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
521 device_class=SensorDeviceClass.ENERGY,
522 state_class=SensorStateClass.TOTAL_INCREASING,
523 formatter=
"format_energy",
526 module_id=
"scb:statistic:EnergyFlow",
527 key=
"Statistic:EnergyPv2:Total",
528 name=
"Energy PV2 Total",
529 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
530 device_class=SensorDeviceClass.ENERGY,
531 state_class=SensorStateClass.TOTAL_INCREASING,
532 formatter=
"format_energy",
535 module_id=
"scb:statistic:EnergyFlow",
536 key=
"Statistic:EnergyPv3:Day",
537 name=
"Energy PV3 Day",
538 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
539 device_class=SensorDeviceClass.ENERGY,
540 state_class=SensorStateClass.TOTAL_INCREASING,
541 formatter=
"format_energy",
544 module_id=
"scb:statistic:EnergyFlow",
545 key=
"Statistic:EnergyPv3:Month",
546 name=
"Energy PV3 Month",
547 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
548 device_class=SensorDeviceClass.ENERGY,
549 state_class=SensorStateClass.TOTAL_INCREASING,
550 formatter=
"format_energy",
553 module_id=
"scb:statistic:EnergyFlow",
554 key=
"Statistic:EnergyPv3:Year",
555 name=
"Energy PV3 Year",
556 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
557 device_class=SensorDeviceClass.ENERGY,
558 state_class=SensorStateClass.TOTAL_INCREASING,
559 formatter=
"format_energy",
562 module_id=
"scb:statistic:EnergyFlow",
563 key=
"Statistic:EnergyPv3:Total",
564 name=
"Energy PV3 Total",
565 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
566 device_class=SensorDeviceClass.ENERGY,
567 state_class=SensorStateClass.TOTAL_INCREASING,
568 formatter=
"format_energy",
571 module_id=
"scb:statistic:EnergyFlow",
572 key=
"Statistic:Yield:Day",
573 name=
"Energy Yield Day",
574 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
575 device_class=SensorDeviceClass.ENERGY,
576 entity_registry_enabled_default=
True,
577 state_class=SensorStateClass.TOTAL_INCREASING,
578 formatter=
"format_energy",
581 module_id=
"scb:statistic:EnergyFlow",
582 key=
"Statistic:Yield:Month",
583 name=
"Energy Yield Month",
584 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
585 device_class=SensorDeviceClass.ENERGY,
586 state_class=SensorStateClass.TOTAL_INCREASING,
587 formatter=
"format_energy",
590 module_id=
"scb:statistic:EnergyFlow",
591 key=
"Statistic:Yield:Year",
592 name=
"Energy Yield Year",
593 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
594 device_class=SensorDeviceClass.ENERGY,
595 state_class=SensorStateClass.TOTAL_INCREASING,
596 formatter=
"format_energy",
599 module_id=
"scb:statistic:EnergyFlow",
600 key=
"Statistic:Yield:Total",
601 name=
"Energy Yield Total",
602 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
603 device_class=SensorDeviceClass.ENERGY,
604 state_class=SensorStateClass.TOTAL_INCREASING,
605 formatter=
"format_energy",
608 module_id=
"scb:statistic:EnergyFlow",
609 key=
"Statistic:EnergyChargeGrid:Day",
610 name=
"Battery Charge from Grid Day",
611 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
612 device_class=SensorDeviceClass.ENERGY,
613 state_class=SensorStateClass.TOTAL_INCREASING,
614 formatter=
"format_energy",
617 module_id=
"scb:statistic:EnergyFlow",
618 key=
"Statistic:EnergyChargeGrid:Month",
619 name=
"Battery Charge from Grid Month",
620 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
621 device_class=SensorDeviceClass.ENERGY,
622 state_class=SensorStateClass.TOTAL_INCREASING,
623 formatter=
"format_energy",
626 module_id=
"scb:statistic:EnergyFlow",
627 key=
"Statistic:EnergyChargeGrid:Year",
628 name=
"Battery Charge from Grid Year",
629 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
630 device_class=SensorDeviceClass.ENERGY,
631 state_class=SensorStateClass.TOTAL_INCREASING,
632 formatter=
"format_energy",
635 module_id=
"scb:statistic:EnergyFlow",
636 key=
"Statistic:EnergyChargeGrid:Total",
637 name=
"Battery Charge from Grid Total",
638 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
639 device_class=SensorDeviceClass.ENERGY,
640 state_class=SensorStateClass.TOTAL_INCREASING,
641 formatter=
"format_energy",
644 module_id=
"scb:statistic:EnergyFlow",
645 key=
"Statistic:EnergyChargePv:Day",
646 name=
"Battery Charge from PV Day",
647 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
648 device_class=SensorDeviceClass.ENERGY,
649 state_class=SensorStateClass.TOTAL_INCREASING,
650 formatter=
"format_energy",
653 module_id=
"scb:statistic:EnergyFlow",
654 key=
"Statistic:EnergyChargePv:Month",
655 name=
"Battery Charge from PV Month",
656 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
657 device_class=SensorDeviceClass.ENERGY,
658 state_class=SensorStateClass.TOTAL_INCREASING,
659 formatter=
"format_energy",
662 module_id=
"scb:statistic:EnergyFlow",
663 key=
"Statistic:EnergyChargePv:Year",
664 name=
"Battery Charge from PV Year",
665 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
666 device_class=SensorDeviceClass.ENERGY,
667 state_class=SensorStateClass.TOTAL_INCREASING,
668 formatter=
"format_energy",
671 module_id=
"scb:statistic:EnergyFlow",
672 key=
"Statistic:EnergyChargePv:Total",
673 name=
"Battery Charge from PV Total",
674 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
675 device_class=SensorDeviceClass.ENERGY,
676 state_class=SensorStateClass.TOTAL_INCREASING,
677 formatter=
"format_energy",
680 module_id=
"scb:statistic:EnergyFlow",
681 key=
"Statistic:EnergyDischarge:Day",
682 name=
"Battery Discharge Day",
683 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
684 device_class=SensorDeviceClass.ENERGY,
685 state_class=SensorStateClass.TOTAL_INCREASING,
686 formatter=
"format_energy",
689 module_id=
"scb:statistic:EnergyFlow",
690 key=
"Statistic:EnergyDischarge:Month",
691 name=
"Battery Discharge Month",
692 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
693 device_class=SensorDeviceClass.ENERGY,
694 state_class=SensorStateClass.TOTAL_INCREASING,
695 formatter=
"format_energy",
698 module_id=
"scb:statistic:EnergyFlow",
699 key=
"Statistic:EnergyDischarge:Year",
700 name=
"Battery Discharge Year",
701 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
702 device_class=SensorDeviceClass.ENERGY,
703 state_class=SensorStateClass.TOTAL_INCREASING,
704 formatter=
"format_energy",
707 module_id=
"scb:statistic:EnergyFlow",
708 key=
"Statistic:EnergyDischarge:Total",
709 name=
"Battery Discharge Total",
710 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
711 device_class=SensorDeviceClass.ENERGY,
712 state_class=SensorStateClass.TOTAL_INCREASING,
713 formatter=
"format_energy",
716 module_id=
"scb:statistic:EnergyFlow",
717 key=
"Statistic:EnergyDischargeGrid:Day",
718 name=
"Energy Discharge to Grid Day",
719 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
720 device_class=SensorDeviceClass.ENERGY,
721 state_class=SensorStateClass.TOTAL_INCREASING,
722 formatter=
"format_energy",
725 module_id=
"scb:statistic:EnergyFlow",
726 key=
"Statistic:EnergyDischargeGrid:Month",
727 name=
"Energy Discharge to Grid Month",
728 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
729 device_class=SensorDeviceClass.ENERGY,
730 state_class=SensorStateClass.TOTAL_INCREASING,
731 formatter=
"format_energy",
734 module_id=
"scb:statistic:EnergyFlow",
735 key=
"Statistic:EnergyDischargeGrid:Year",
736 name=
"Energy Discharge to Grid Year",
737 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
738 device_class=SensorDeviceClass.ENERGY,
739 state_class=SensorStateClass.TOTAL_INCREASING,
740 formatter=
"format_energy",
743 module_id=
"scb:statistic:EnergyFlow",
744 key=
"Statistic:EnergyDischargeGrid:Total",
745 name=
"Energy Discharge to Grid Total",
746 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
747 device_class=SensorDeviceClass.ENERGY,
748 state_class=SensorStateClass.TOTAL_INCREASING,
749 formatter=
"format_energy",
752 module_id=
"scb:event",
753 key=
"Event:ActiveErrorCnt",
754 name=
"Active Alarms",
755 entity_category=EntityCategory.DIAGNOSTIC,
756 entity_registry_enabled_default=
False,
758 formatter=
"format_round",
763 name=
"Sum power of all PV DC inputs",
764 native_unit_of_measurement=UnitOfPower.WATT,
765 device_class=SensorDeviceClass.POWER,
766 entity_registry_enabled_default=
True,
767 state_class=SensorStateClass.MEASUREMENT,
768 formatter=
"format_round",
772 key=
"Statistic:EnergyGrid:Total",
773 name=
"Energy to Grid Total",
774 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
775 device_class=SensorDeviceClass.ENERGY,
776 state_class=SensorStateClass.TOTAL_INCREASING,
777 formatter=
"format_energy",
781 key=
"Statistic:EnergyGrid:Year",
782 name=
"Energy to Grid Year",
783 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
784 device_class=SensorDeviceClass.ENERGY,
785 state_class=SensorStateClass.TOTAL_INCREASING,
786 formatter=
"format_energy",
790 key=
"Statistic:EnergyGrid:Month",
791 name=
"Energy to Grid Month",
792 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
793 device_class=SensorDeviceClass.ENERGY,
794 state_class=SensorStateClass.TOTAL_INCREASING,
795 formatter=
"format_energy",
799 key=
"Statistic:EnergyGrid:Day",
800 name=
"Energy to Grid Day",
801 native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
802 device_class=SensorDeviceClass.ENERGY,
803 state_class=SensorStateClass.TOTAL_INCREASING,
804 formatter=
"format_energy",
810 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
812 """Add kostal plenticore Sensors."""
813 plenticore = hass.data[DOMAIN][entry.entry_id]
817 available_process_data = await plenticore.client.get_process_data()
825 for description
in SENSOR_PROCESS_DATA:
826 module_id = description.module_id
827 data_id = description.key
829 module_id
not in available_process_data
830 or data_id
not in available_process_data[module_id]
833 "Skipping non existing process data %s/%s", module_id, data_id
839 process_data_update_coordinator,
843 plenticore.device_info,
851 CoordinatorEntity[ProcessDataUpdateCoordinator], SensorEntity
853 """Representation of a Plenticore data Sensor."""
855 entity_description: PlenticoreSensorEntityDescription
859 coordinator: ProcessDataUpdateCoordinator,
860 description: PlenticoreSensorEntityDescription,
863 device_info: DeviceInfo,
865 """Create a new Sensor Entity for Plenticore process data."""
872 self._formatter: Callable[[str], Any] = PlenticoreDataFormatter.get_method(
873 description.formatter
878 self.
_attr_name_attr_name = f
"{platform_name} {description.name}"
882 """Return if entity is available."""
885 and self.coordinator.data
is not None
886 and self.
module_idmodule_id
in self.coordinator.data
891 """Register this entity on the Update Coordinator."""
898 """Unregister this entity from the Update Coordinator."""
904 """Return the state of the sensor."""
905 if self.coordinator.data
is None:
909 raw_value = self.coordinator.data[self.
module_idmodule_id][self.
data_iddata_id]
911 return self._formatter(raw_value)
None stop_fetch_data(self, str module_id, str data_id)
CALLBACK_TYPE start_fetch_data(self, str module_id, str data_id)
None async_added_to_hass(self)
None __init__(self, ProcessDataUpdateCoordinator coordinator, PlenticoreSensorEntityDescription description, str entry_id, str platform_name, DeviceInfo device_info)
None async_will_remove_from_hass(self)
StateType native_value(self)
None async_on_remove(self, CALLBACK_TYPE func)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)