about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthew Garrett <mjg59@coreos.com>2016-10-10T08·09-0700
committerMatthew Garrett <mjg59@coreos.com>2016-10-10T08·09-0700
commit6936bc750ee00e495556eee6a28f240020bec945 (patch)
tree403df6586d1564ba239a4892ef0a20e17226ea46
parentecab016a73eee8d018a4b8617eb2c2680dbc284d (diff)
Attempt to handle timezones
The timezone should be embedded in the discovery packet, so make a better
attempt to do that.
-rwxr-xr-xbroadlink/__init__.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/broadlink/__init__.py b/broadlink/__init__.py
index c981d6b3eaa4..2891052708a3 100755
--- a/broadlink/__init__.py
+++ b/broadlink/__init__.py
@@ -25,14 +25,21 @@ class rm2:
     self.cs.bind(('',0)) 
     self.port = self.cs.getsockname()[1]
 
+    timezone = time.timezone/-3600
     packet = bytearray(0x30)
 
     year = datetime.now().year
 
-    packet[0x08] = 0xf9
-    packet[0x09] = 0xff
-    packet[0x0a] = 0xff
-    packet[0x0b] = 0xff
+    if timezone < 0:
+      packet[0x08] = 0xff + timezone - 1
+      packet[0x09] = 0xff
+      packet[0x0a] = 0xff
+      packet[0x0b] = 0xff
+    else:
+      packet[0x08] = timezone
+      packet[0x09] = 0
+      packet[0x0a] = 0
+      packet[0x0b] = 0
     packet[0x0c] = year & 0xff
     packet[0x0d] = year >> 8
     packet[0x0e] = datetime.now().minute