Whole file

marcelblijleven/goodwe

The author described this change as Fix decoding 0 energy values. It counts as a record because the check below fails on the code as it stood at 366d35652 and passes on a555e3e72, with nothing else changed between the two runs.

Fix saved2024-05-14
Sharing licenceMIT · LICENSE
Change size+2 2

What the code was meant to do, written into the code itself as a save note

Fix decoding 0 energy values

The change

183183
184184 def read_value(self, data: ProtocolResponse):
185185 value = read_bytes2(data)
186- return float(value) / 10 if value else None
186+ return float(value) / 10 if value is not None else None
187187
188188
189189 class Energy4(Sensor):
194194
195195 def read_value(self, data: ProtocolResponse):
196196 value = read_bytes4(data)
197- return float(value) / 10 if value else None
197+ return float(value) / 10 if value is not None else None
198198
199199
200200 class Apparent(Sensor):

The check that tells the two apart

failpass·tests/test_dt.py::GW5000D_NS_Test::test_GW5000D_NS_runtime_data

Check file tests/test_dt.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it366d35652752ff8207ae7b0ae0767d0e30391180
Broken version dated2024-05-14
Modulegoodwe.sensor
Units changedEnergy, Energy4
Fingerprint3576d940d8c693c3
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in marcelblijleven/goodwe