diff options
author | Eugene Schava <eschava@gmail.com> | 2017-07-15T23·30+0300 |
---|---|---|
committer | Matthew Garrett <mjg59@google.com> | 2017-11-25T20·11-0800 |
commit | 2160488da23f54adc6dfc8728167385e2c59eb45 (patch) | |
tree | f62ec73db6fbe5c355ee66b2b414b1ba6dc8e41f /broadlink | |
parent | 626b459b5b13931008fdaaf3b6261dd8bc9c2e33 (diff) |
sp2.get_energy
Diffstat (limited to 'broadlink')
-rw-r--r-- | broadlink/__init__.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index eb945a7d96fe..ee74b8843fd0 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -386,6 +386,16 @@ class sp2(device): state = bool(ord(payload[0x4])) return state + def get_energy(self): + packet = bytearray([8, 0, 254, 1, 5, 1, 0, 0, 0, 45]) + response = self.send_packet(0x6a, packet) + err = response[0x22] | (response[0x23] << 8) + if err == 0: + payload = self.decrypt(bytes(response[0x38:])) + energy = int(hex(ord(payload[7]) * 256 + ord(payload[6]))[2:]) + int(hex(ord(payload[5]))[2:])/100.0 + return energy + + class a1(device): def __init__ (self, host, mac): device.__init__(self, host, mac) |