Skip to content

Commit

Permalink
Fix decoding of N/A temperatures
Browse files Browse the repository at this point in the history
  • Loading branch information
mletenay committed May 3, 2024
1 parent 070be83 commit 143ec25
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion goodwe/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,10 @@ def read_temp(buffer: ProtocolResponse, offset: int = None) -> float:
if offset is not None:
buffer.seek(offset)
value = int.from_bytes(buffer.read(2), byteorder="big", signed=True)
return float(value) / 10
if (value == 32767):
return None
else:
return float(value) / 10


def read_datetime(buffer: ProtocolResponse, offset: int = None) -> datetime:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_et.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ def test_GW6000_EH_runtime_data(self):
self.assertSensor('backup_ptotal', 0, 'W', data)
self.assertSensor('ups_load', 0, '%', data)
self.assertSensor('temperature_air', 60.4, 'C', data)
self.assertSensor('temperature_module', 3276.7, 'C', data)
self.assertSensor('temperature_module', None, 'C', data)
self.assertSensor('temperature', 38.6, 'C', data)
self.assertSensor('function_bit', 256, '', data)
self.assertSensor('bus_voltage', 380.6, 'V', data)
Expand Down

0 comments on commit 143ec25

Please sign in to comment.