Whole file
marcelblijleven/goodwe
The author described this change as “Fix decoding of voltage values”. It counts as a record because the checks below fail on the code as it stood at 925f37d51 and pass on c2f1de07f, with nothing else changed between the two runs.
Projectmarcelblijleven/goodwe
Fix saved2024-04-08
Sharing licenceMIT · LICENSE
Change size+3 −3
What the code was meant to do, written into the code itself as a save note
Fix decoding of voltage values
The change
| 739 | 739 | """Retrieve voltage [V] value (2 bytes) from buffer""" | |
| 740 | 740 | if offset is not None: | |
| 741 | 741 | buffer.seek(offset) | |
| 742 | - | value = int.from_bytes(buffer.read(2), byteorder="big", signed=True) | |
| 743 | - | return float(value) / 10 | |
| 742 | + | value = int.from_bytes(buffer.read(2), byteorder="big", signed=False) | |
| 743 | + | return float(value) / 10 if value != 0xffff else 0 | |
| 744 | 744 | ||
| 745 | 745 | ||
| 746 | 746 | def encode_voltage(value: Any) -> bytes: | |
| 747 | 747 | """Encode voltage value to raw (2 bytes) payload""" | |
| 748 | - | return int.to_bytes(int(value * 10), length=2, byteorder="big", signed=True) | |
| 748 | + | return int.to_bytes(int(value * 10), length=2, byteorder="big", signed=False) | |
| 749 | 749 | ||
| 750 | 750 | ||
| 751 | 751 | def read_current(buffer: ProtocolResponse, offset: int = None) -> float: |
The check that tells the two apart
fail→pass·tests/test_dt.py::GW5000D_NS_Test::test_GW5000D_NS_runtime_data
fail→pass·tests/test_dt.py::GW5000_MS_Test::test_GW5000_MS_runtime_data
fail→pass·tests/test_dt.py::GW6000_DT_Test::test_GW6000_DT_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 it925f37d51d7d0370d1220d55e7f95b3cf06e16f1
Broken version dated2024-02-17
Modulegoodwe.sensor
Units changedencode_voltage, read_voltage
Fingerprinteaf546202b5ecb6a
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
- 2026-03-29Fix duplicate sensor registrations
- 2024-05-14Fix decoding 0 energy values
- 2024-05-12Fix writing single byte settings on ES inverters
- 2024-05-08Fix setup of BT inverters
- 2024-01-09Fix deconding 0x55 as not-set value of EcoMode
- 2023-12-31Fix unit of current MPPT sensors