@@ -284,6 +284,15 @@ def ir_receiver(self) -> "TasmotaIRReceiverConnector":
284
284
"""
285
285
return self ._get_or_create_connector (TasmotaIRReceiverConnector )
286
286
287
+ def energy (self ) -> "TasmotaEnergyConnector" :
288
+ """
289
+ Returns a *subscribable* :class:`float`-typed Connector, publishing the currently measured power consumption
290
+ values in from the Tasmota device.
291
+
292
+ Unavailable power/energy values are set to NaN.
293
+ """
294
+ return self ._get_or_create_connector (TasmotaEnergyConnector )
295
+
287
296
def energy_power (self ) -> "TasmotaEnergyPowerConnector" :
288
297
"""
289
298
Returns a *subscribable* :class:`float`-typed Connector, publishing the currently measured power consumption in
@@ -597,6 +606,52 @@ def _decode(self, value: JSONType) -> float:
597
606
return float (value ['Factor' ])
598
607
599
608
609
+ class TasmotaEnergyMeasurement (NamedTuple ):
610
+ #: the currently measured power consumption in W
611
+ power : float
612
+ #: the currently measured mains voltage in V
613
+ voltage : float
614
+ #: the currently measured current flow in A
615
+ current : float
616
+ #: the currently measured apparent power in VA
617
+ apparent_power : float
618
+ #: the currently measured reactive power in VAr
619
+ reactive_power : float
620
+ #: the currently measured power factor
621
+ power_factor : float
622
+ #: the currently measured mains frequency in Hz
623
+ frequency : float
624
+ #: the total energy consumption in kWh
625
+ total_energy : float
626
+ #: today's energy consumption in kWh
627
+ total_energy_today : float
628
+ #: yesterday's energy consumption in kWh
629
+ total_energy_yesterday : float
630
+
631
+
632
+ class TasmotaEnergyConnector (AbstractTasmotaConnector [TasmotaEnergyMeasurement ]):
633
+ type = TasmotaEnergyMeasurement
634
+ NAN = float ('NaN' )
635
+
636
+ def __init__ (self , _interface : TasmotaInterface ):
637
+ super ().__init__ ("ENERGY" )
638
+
639
+ def _decode (self , value : JSONType ) -> TasmotaEnergyMeasurement :
640
+ assert isinstance (value , dict )
641
+ return TasmotaEnergyMeasurement (
642
+ float (value .get ('Power' , self .NAN )),
643
+ float (value .get ('Voltage' , self .NAN )),
644
+ float (value .get ('Current' , self .NAN )),
645
+ float (value .get ('ApparentPower' , self .NAN )),
646
+ float (value .get ('ReactivePower' , self .NAN )),
647
+ float (value .get ('Factor' , self .NAN )),
648
+ float (value .get ('Frequency' , self .NAN )),
649
+ float (value .get ('Total' , self .NAN )),
650
+ float (value .get ('Today' , self .NAN )),
651
+ float (value .get ('Yesterday' , self .NAN )),
652
+ )
653
+
654
+
600
655
class TasmotaOnlineConnector (Readable [bool ], Subscribable [bool ]):
601
656
type = bool
602
657
0 commit comments