This commit is contained in:
2020-12-28 22:45:53 +01:00
parent 53b8d957cd
commit 71f58713fc
+8 -2
View File
@@ -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)