1
0
Fork 0

calculate midnight on iteration to deal with DST changes

Bob Carroll 2023-11-06 20:13:04 -06:00
parent 0a5e69c730
commit 4a0e54cab2
1 changed files with 4 additions and 4 deletions

View File

@ -157,14 +157,14 @@ async def periodic_rule_check(client, chain, timezone, scene, state, mutex):
:param state: shared state dictionary
:param mutex: lock for making changes to shared state
"""
midnight = timezone.localize(
datetime.combine(now(timezone), datetime.min.time()))
logging.debug(f'Setting time zone to {midnight.tzname()}')
while True:
logging.debug('Begin rule check')
await mutex.acquire()
midnight = timezone.localize(
datetime.combine(now(timezone), datetime.min.time()))
logging.debug(f'Setting time zone to {midnight.tzname()}')
if now(timezone) >= midnight:
for rule in chain.walk():
if now(timezone).time() < rule.time: