44import datetime
55import errno
66import logging
7- import time
87import threading
98import warnings
109import socket
@@ -342,7 +341,7 @@ def datagram_received(self, data: bytes, addr):
342341 if discover_ip and discover_serial :
343342 self .hubs .add ( (discover_ip , discover_serial ) )
344343
345- def __init__ (self , serial , ip = None , discover = True , loop = None , synchronous = True ):
344+ def __init__ (self , serial , ip = None , discover = True , loop = None , synchronous = True , timezone : datetime . tzinfo = None ):
346345 """
347346 Initialize logger and dictionaries.
348347
@@ -359,6 +358,7 @@ def __init__(self, serial, ip=None, discover=True, loop=None, synchronous=True):
359358 if loop is not None :
360359 _LOGGER .warning ("loop is deprecated. Use synchronous=False instead." )
361360 synchronous = False
361+ self .timezone = timezone
362362
363363 self ._callbacks = []
364364 self ._reader = None
@@ -491,7 +491,8 @@ async def async_connect_hub(self, ip, serial):
491491 self ._reader , self ._writer = await asyncio .wait_for (asyncio .open_connection (ip , 27779 ), timeout = 5 )
492492
493493 # start handshake: "HELLO <version of command set> <Hub s.no.> <date and time in format 'yyyyMMddHHmmss'>\r"
494- await self .async_send_command ([nobo .API .START , nobo .API .VERSION , serial , time .strftime ('%Y%m%d%H%M%S' )])
494+ now = datetime .datetime .now (self .timezone ).strftime ('%Y%m%d%H%M%S' )
495+ await self .async_send_command ([nobo .API .START , nobo .API .VERSION , serial , now ])
495496
496497 # receive the response data (4096 is recommended buffer size)
497498 response = await asyncio .wait_for (self .get_response (), timeout = 5 )
0 commit comments