diff options
author | Dominik Lakatoš <deel77@gmail.com> | 2018-02-08T12·47+0100 |
---|---|---|
committer | Dominik Lakatoš <deel77@gmail.com> | 2018-02-08T12·47+0100 |
commit | 51ff890c7ca7f5569497b47db6497e908a94267a (patch) | |
tree | ee1bcc4927503a941c21f3d5f706bcb924a09952 /broadlink/__init__.py | |
parent | dd0e9083172d1ee54eec167d342edb3b157aea4c (diff) |
modified get_energy() to support python3
Diffstat (limited to 'broadlink/__init__.py')
-rw-r--r-- | broadlink/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py index dbabce0b3494..50d9f940119c 100644 --- a/broadlink/__init__.py +++ b/broadlink/__init__.py @@ -397,7 +397,10 @@ class sp2(device): 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 + if type(payload[0x07]) == int: + energy = int(hex(payload[0x07] * 256 + payload[0x06])[2:]) + int(hex(payload[0x05])[2:])/100.0 + else: + energy = int(hex(ord(payload[0x07]) * 256 + ord(payload[0x06]))[2:]) + int(hex(ord(payload[0x05]))[2:])/100.0 return energy |