From a13fc1d92ad263f5264ef6bd46a09b92c8ec4f93 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 11 Nov 2022 15:57:52 +0100 Subject: [PATCH] RPI: fix SunsetHandler - use correct (utc) timestamp for comparision --- tools/rpi/hoymiles/__main__.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/rpi/hoymiles/__main__.py b/tools/rpi/hoymiles/__main__.py index 5f783ac4..97c7c139 100644 --- a/tools/rpi/hoymiles/__main__.py +++ b/tools/rpi/hoymiles/__main__.py @@ -48,24 +48,24 @@ class SunsetHandler: longitude = sunset_config.get('longitude') altitude = sunset_config.get('altitude') self.suntimes = SunTimes(longitude=longitude, latitude=latitude, altitude=altitude) - self.nextSunset = self.suntimes.setutc(datetime.now()) - print (f'Todays sunset is at {self.nextSunset}') + self.nextSunset = self.suntimes.setutc(datetime.utcnow()) + print (f'Todays sunset is at {self.nextSunset} UTC') def checkWaitForSunrise(self): if not self.suntimes: return # if the sunset already happened for today - now = datetime.now() + now = datetime.utcnow() if self.nextSunset < now: # wait until the sun rises tomorrow tomorrow = now + timedelta(days=1) nextSunrise = self.suntimes.riseutc(tomorrow) self.nextSunset = self.suntimes.setutc(tomorrow) time_to_sleep = (nextSunrise - datetime.now()).total_seconds() - print (f'Waiting for sunrise at {nextSunrise} ({time_to_sleep} seconds)') + print (f'Waiting for sunrise at {nextSunrise} UTC ({time_to_sleep} seconds)') if time_to_sleep > 0: time.sleep(time_to_sleep) - print (f'Woke up... next sunset is at {self.nextSunset}') + print (f'Woke up... next sunset is at {self.nextSunset} UTC') return def main_loop(ahoy_config):