Repository: marcelblijleven/goodwe (language: python)

Issue:
PPV negative value on ET inverter
Hi, 

I have a GW3600-EH inverter and some months ago I started to get a -2 W read on the ppv sensor when there is no solar production.

I was debugging the code and the problem seems to be on this line 
https://github.com/marcelblijleven/goodwe/blob/29de1c4303fffd3e984eb3314db4b5085fbaf334/goodwe/et.py#L35-L41
Although a filter to reject the `ppv3` and `ppv4` values is used, the `ppv` sensor gets populated using the Calculated class using a lambda function that pulls all the 4 current power.

The issue is that when accessing the `ppv3` and `ppv4` using the `read_bytes4`, the function returns a -1, therefore the sum will be `0+0+(-1)+(-1)`.

Could you help me to solve this issue? I don't know exactly how we could avoid reading this values?

Thanks!


Discussion / hints:
something like this would solve it
```
Calculated("ppv",
                   lambda data:
                   max(0, read_bytes4(data, 10)) +
                   max(0, read_bytes4(data, 18)) +
                   max(0, read_bytes4(data, 26)) +
                   max(0, read_bytes4(data, 34)),
                   "PV Power", "W", Kind.PV),
```

this just sets that is the value of the read_byte4 is a negative value set it to 0
so `0+0+(-1)+(-1)` would become `0+0+(0)+(0)`
Hello,
this might be problem of inverter calibration from production - in my case GW10K-ET I have problem with offset between -0,3 and -0,2A on battery current measurement, so in cosequence it also incorrectly calculates battery energy charged. The same problem is visible in PVMaster / SolarGo. I solve it for more than 6 months with GoodWe support.
Regards,
Jan
Hi @jenicek001,

I'm 100% sure the problem is not on the inverter as I was debugging the code. I'll try the solution @oziee suggest tonight and I'll update here.

Thanks

Fix patch:
diff --git a/goodwe/et.py b/goodwe/et.py
index dc80fc4..e558209 100644
--- a/goodwe/et.py
+++ b/goodwe/et.py
@@ -34,10 +34,10 @@ class ET(Inverter):
         # ppv1 + ppv2 + ppv3 + ppv4
         Calculated("ppv",
                    lambda data:
-                   read_bytes4(data, 10) +
-                   read_bytes4(data, 18) +
-                   read_bytes4(data, 26) +
-                   read_bytes4(data, 34),
+                   max(0, read_bytes4(data, 10)) +
+                   max(0, read_bytes4(data, 18)) +
+                   max(0, read_bytes4(data, 26)) +
+                   max(0, read_bytes4(data, 34)),
                    "PV Power", "W", Kind.PV),
         Byte("pv4_mode", 38, "PV4 Mode code", "", Kind.PV),
         Enum("pv4_mode_label", 38, PV_MODES, "PV4 Mode", Kind.PV),


Test patch:
diff --git a/tests/test_et.py b/tests/test_et.py
index 7e2516e..f9d6fbe 100644
--- a/tests/test_et.py
+++ b/tests/test_et.py
@@ -393,7 +393,7 @@ def test_GW6000_EH_runtime_data(self):
         self.assertSensor('vpv2', 329.6, 'V', data)
         self.assertSensor('ipv2', 2.1, 'A', data)
         self.assertSensor('ppv2', 691, 'W', data)
-        self.assertSensor('ppv', 1546, 'W', data)
+        self.assertSensor('ppv', 1548, 'W', data)
         self.assertSensor('pv1_mode', 2, '', data)
         self.assertSensor('pv1_mode_label', 'PV panels connected, producing power', '', data)
         self.assertSensor('pv2_mode', 2, '', data)
@@ -641,7 +641,7 @@ def test_GW6000_EH_runtime_data(self):
         self.assertSensor('vpv2', 329.6, 'V', data)
         self.assertSensor('ipv2', 2.1, 'A', data)
         self.assertSensor('ppv2', 691, 'W', data)
-        self.assertSensor('ppv', 1546, 'W', data)
+        self.assertSensor('ppv', 1548, 'W', data)
         self.assertSensor('pv1_mode', 2, '', data)
         self.assertSensor('pv1_mode_label', 'PV panels connected, producing power', '', data)
         self.assertSensor('pv2_mode', 2, '', data)