From 63d184fc8ceb44362e321ed13c3084dfe82e0f8f Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Sat, 3 Dec 2016 16:41:10 -0800 Subject: [PATCH] Provide raw sensor data Provide raw versions of the sensor data for interpretation by clients --- broadlink/__init__.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 94446fc2f..f4bb1069c 100755 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -331,6 +331,29 @@ class a1(device): data['noise'] = 'unknown' return data + def check_sensors_raw(self): + packet = bytearray(16) + packet[0] = 1 + response = self.send_packet(0x6a, packet) + err = response[0x22] | (response[0x23] << 8) + if err == 0: + data = {} + aes = AES.new(bytes(self.key), AES.MODE_CBC, bytes(self.iv)) + payload = aes.decrypt(bytes(response[0x38:])) + if type(payload[0x4]) == int: + data['temperature'] = (payload[0x4] * 10 + payload[0x5]) / 10.0 + data['humidity'] = (payload[0x6] * 10 + payload[0x7]) / 10.0 + data['light'] = payload[0x8] + data['air_quality'] = payload[0x0a] + data['noise'] = payload[0xc] + else: + data['temperature'] = (ord(payload[0x4]) * 10 + ord(payload[0x5])) / 10.0 + data['humidity'] = (ord(payload[0x6]) * 10 + ord(payload[0x7])) / 10.0 + data['light'] = ord(payload[0x8]) + data['air_quality'] = ord(payload[0x0a]) + data['noise'] = ord(payload[0xc]) + return data + class rm(device): def __init__ (self, host, mac):