.
This commit is contained in:
+8
-2
@@ -18,7 +18,9 @@ class MsgwWorker(BaseWorker):
|
||||
self.ser = serial.Serial(self.port, self.baudrate, timeout=10)
|
||||
if not hasattr(self, 'encoding'):
|
||||
self.encoding = 'utf-8'
|
||||
|
||||
if not hasattr(self, 'timezone'):
|
||||
self.timezone = 1
|
||||
|
||||
def config(self):
|
||||
return []
|
||||
|
||||
@@ -45,7 +47,11 @@ class MsgwWorker(BaseWorker):
|
||||
if command == 3:
|
||||
# I_TIME
|
||||
if ctype == 1:
|
||||
timevalue = str(60*60+int(time.mktime(time.localtime())))
|
||||
tm = time.localtime()
|
||||
offset = self.timezone
|
||||
if tm.tm_isdst == 1:
|
||||
offset += 1
|
||||
timevalue = str(offset*60*60+int(time.mktime(tm)))
|
||||
resp = str.encode(splited_line[0]+";"+splited_line[1]+";3;0;1;"+timevalue+"\n")
|
||||
self.ser.write(resp)
|
||||
_LOGGER.error(self.LOGNAME + ": time request received, sending back %s" % resp)
|
||||
|
||||
Reference in New Issue
Block a user