diff options
author | Matthew Garrett <mjg59@coreos.com> | 2016-12-04T00·41-0800 |
---|---|---|
committer | Matthew Garrett <mjg59@coreos.com> | 2016-12-04T00·41-0800 |
commit | 63d184fc8ceb44362e321ed13c3084dfe82e0f8f (patch) | |
tree | dfe064c56800083eca72ded3d9000229d78a45a0 /broadlink | |
parent | d10a43531c423f87f2cb7170646c32120476431a (diff) |
Provide raw sensor data
Provide raw versions of the sensor data for interpretation by clients
Diffstat (limited to 'broadlink')
-rwxr-xr-x | broadlink/__init__.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index 94446fc2ff74..f4bb1069caa1 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): |