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