diff --git a/hydrobot.py b/hydrobot.py --- a/hydrobot.py +++ b/hydrobot.py @@ -12,6 +12,7 @@ from influxdb import InfluxDBClient from influxdb import SeriesHelper from apscheduler.schedulers.background import BackgroundScheduler import PID +from pytz import timezone #TODO #fix temperature offsets @@ -147,6 +148,7 @@ class Scheduler: def __init__(self, canbus): self.canbus = canbus self.apscheduler = BackgroundScheduler() + self.apscheduler.configure(timezone=timezone('US/Eastern')) def start(self): self.apscheduler.start() @@ -172,7 +174,7 @@ class Scheduler: if trigger == 'cron': on_job = self.apscheduler.add_job(self.canbus.set_output, trigger, [module, output, 1], day = on_time[0], day_of_week = on_time[1], hour = on_time[2], minute = on_time[3], second = on_time[4]) off_job = self.apscheduler.add_job(self.canbus.set_output, trigger, [module, output, 0], day = off_time[0], day_of_week = off_time[1], hour = off_time[2], minute = off_time[3], second = off_time[4]) - + #evalute the current state of the cron trigger and set output on if needed if on_job.next_run_time > off_job.next_run_time: self.canbus.set_output(module, output, 1)