Skip to content

Commit

Permalink
Merge pull request #27 from uduncanu/lywsd02-history
Browse files Browse the repository at this point in the history
Change _process_history_data to use a single unpack
  • Loading branch information
h4 authored Jan 3, 2021
2 parents 2de71fc + c7a6da1 commit 2ba1168
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lywsd02/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ def _process_sensor_data(self, data):
self._data = SensorData(temperature=temperature, humidity=humidity)

def _process_history_data(self, data):

# TODO unpacking with IIhBhB in one step doesn't work
(idx, ts) = struct.unpack_from('II', data[0:8])
(max_temp, max_hum) = struct.unpack_from('hB', data[8:11])
(min_temp, min_hum) = struct.unpack_from('hB', data[11:14])
(idx, ts, max_temp, max_hum, min_temp, min_hum) = struct.unpack_from('<IIhBhB', data)

ts = datetime.fromtimestamp(ts)
min_temp /= 100
Expand Down

0 comments on commit 2ba1168

Please sign in to comment.