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 cb2481c46e
2 changed files with 5 additions and 6 deletions

View File

@ -149,7 +149,6 @@ async def periodic_rule_check(client, chain, timezone, scene, state, mutex):
"""
Periodically checks for a matching rule to apply.
nstalling collected packages: cherry-hue
:param client: mqtt client
:param chain: the head of a rule chain
:param timezone: local time zone object
@ -157,14 +156,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:

View File

@ -2,7 +2,7 @@
from setuptools import setup, find_namespace_packages
setup(name='cherry-bedtime',
version='0.2',
version='0.3',
description='Simulates a sunset as bedtime approaches',
author='Bob Carroll',
author_email='bob.carroll@alum.rit.edu',