From af37231f5b3cef0ad33a467062d6b5ea6846d1f6 Mon Sep 17 00:00:00 2001 From: Matthew Exon Date: Sat, 19 Jun 2021 14:18:59 +0200 Subject: [PATCH] Fix calculation of 16-bit integers --- contrib/python/scan-thermometer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/python/scan-thermometer.py b/contrib/python/scan-thermometer.py index 5f13b6c2..5a8ba933 100644 --- a/contrib/python/scan-thermometer.py +++ b/contrib/python/scan-thermometer.py @@ -24,10 +24,10 @@ def parseData(self, val): return { 'timestamp': datetime.now().astimezone().replace(microsecond=0).isoformat(), 'mac': ":".join(["{:02X}".format(bytes[i]) for i in range(2,8)]), - 'temperature': (bytes[8] * 16 + bytes[9]) / 10, + 'temperature': (bytes[8] * 256 + bytes[9]) / 10, 'humidity': bytes[10], 'battery_percent': bytes[11], - 'battery_volt': (bytes[12] * 16 + bytes[13]) / 1000, + 'battery_volt': (bytes[12] * 256 + bytes[13]) / 1000, 'count': bytes[14], }