1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-09-21 04:20:36 +02:00

Attempt to handle timezones

The timezone should be embedded in the discovery packet, so make a better
attempt to do that.
This commit is contained in:
Matthew Garrett 2016-10-10 01:09:06 -07:00
parent ecab016a73
commit 6936bc750e

View File

@ -25,14 +25,21 @@ class rm2:
self.cs.bind(('',0)) self.cs.bind(('',0))
self.port = self.cs.getsockname()[1] self.port = self.cs.getsockname()[1]
timezone = time.timezone/-3600
packet = bytearray(0x30) packet = bytearray(0x30)
year = datetime.now().year year = datetime.now().year
packet[0x08] = 0xf9 if timezone < 0:
packet[0x09] = 0xff packet[0x08] = 0xff + timezone - 1
packet[0x0a] = 0xff packet[0x09] = 0xff
packet[0x0b] = 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[0x0c] = year & 0xff
packet[0x0d] = year >> 8 packet[0x0d] = year >> 8
packet[0x0e] = datetime.now().minute packet[0x0e] = datetime.now().minute