diff --git a/README.md b/README.md index bae959a..88fe69c 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,6 @@ This plugin: - Connects to the myenergi backend and thus needs a working internet connection. - Only takes Zappi devices into account for now; Eddi devices are ignored. -Domoticz: - -- Seems to incorrectly display daily values for the computed total kWh values. This likely screws up the displayed 'Grid' values. See https://github.com/domoticz/domoticz/issues/4736 - ## Updating Like other plugins, in the Domoticz-myenergi directory: diff --git a/plugin.py b/plugin.py index 337f40d..f25b9f4 100644 --- a/plugin.py +++ b/plugin.py @@ -8,7 +8,7 @@ # https://github.com/twonk/MyEnergi-App-Api """ - +

myenergi Plugin


Features

@@ -65,11 +65,13 @@ def onStart(self): if len(Devices) < 1: Domoticz.Device(Name="Generation", Unit=1, TypeName='kWh', Switchtype=4, Options={'EnergyMeterMode':'1'}).Create() if len(Devices) < 2: - Domoticz.Device(Name="Grid", Unit=2, TypeName='kWh', Options={'EnergyMeterMode':'1'}).Create() + Domoticz.Device(Name="Grid Import", Unit=2, TypeName='kWh', Options={'EnergyMeterMode':'1'}).Create() if len(Devices) < 3: Domoticz.Device(Name="Car Charging", Unit=3, TypeName='kWh', Options={'EnergyMeterMode':'1'}).Create() if len(Devices) < 4: Domoticz.Device(Name="Home Consumption", Unit=4, TypeName='kWh', Options={'EnergyMeterMode':'1'}).Create() + if len(Devices) < 5: + Domoticz.Device(Name="Grid Export", Unit=5, TypeName='kWh', Options={'EnergyMeterMode':'1'}).Create() DumpConfigToLog() @@ -138,10 +140,17 @@ def onHeartbeat(self): else: # TODO - Find a way to get total counters from the API instead of letting Domoticz compute Devices[1].Update(nValue=0, sValue=str(zappi_gen_watt)+";0") - Devices[2].Update(nValue=0, sValue=str(zappi_grd_watt)+";0") Devices[3].Update(nValue=0, sValue=str(zappi_div_watt)+";0") Devices[4].Update(nValue=0, sValue=str(zappi_hom_watt)+";0") + # Work around negative kWh Domoticz issue #4736 using separate import and export grid meters + if (zappi_grd_watt < 0): + Devices[5].Update(nValue=0, sValue=str(abs(zappi_grd_watt))+";0") # (-) Grid export + Devices[2].Update(nValue=0, sValue="0;0") + else: + Devices[2].Update(nValue=0, sValue=str(zappi_grd_watt)+";0") # (+) Grid import + Devices[5].Update(nValue=0, sValue="0;0") + break self.lastPolled += 1