about summary refs log tree commit diff
path: root/broadlink
diff options
context:
space:
mode:
authorDaniel Høyer Iversen <mail@dahoiv.net>2018-04-15T17·04+0200
committerGitHub <noreply@github.com>2018-04-15T17·04+0200
commit9c238e17174a6ea2b0522e2a4a1ac1552a185c23 (patch)
tree313dece7e799bbf0a0b7b2004ba2fdfa01eef262 /broadlink
parent3b6b55ae73dd4fffd3f3e089ca6a7912ff0fdf79 (diff)
parente8421343e3067b0c3a5f40c368b3b8566206a0c5 (diff)
Merge pull request #178 from lordneon/master
Fixed a bug within the SP2 class.
Diffstat (limited to 'broadlink')
-rw-r--r--broadlink/__init__.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py
index a3fadf5dd93e..a5415c23dc7a 100644
--- a/broadlink/__init__.py
+++ b/broadlink/__init__.py
@@ -417,10 +417,16 @@ class sp2(device):
     err = response[0x22] | (response[0x23] << 8)
     if err == 0:
       payload = self.decrypt(bytes(response[0x38:]))
-      if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3:
-        state = True
+      if type(payload[0x4]) == int:
+        if payload[0x4] == 1 or payload[0x4] == 3:
+          state = True
+        else:
+          state = False
       else:
-        state = False
+        if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3:
+          state = True
+        else:
+          state = False
       return state
 
   def check_nightlight(self):
@@ -431,10 +437,16 @@ class sp2(device):
     err = response[0x22] | (response[0x23] << 8)
     if err == 0:
       payload = self.decrypt(bytes(response[0x38:]))
-      if ord(payload[0x4]) == 2 or ord(payload[0x4]) == 3:
-        state = True
+      if type(payload[0x4]) == int:
+        if payload[0x4] == 2 or payload[0x4] == 3:
+          state = True
+        else:
+          state = False
       else:
-        state = False
+        if ord(payload[0x4]) == 2 or ord(payload[0x4]) == 3:
+          state = True
+        else:
+          state = False
       return state
 
   def get_energy(self):