Fixed running seek on auto restart bug.

This commit is contained in:
James Kirikland Garner 2022-12-24 13:56:07 -08:00
parent ee70ba1667
commit b960bb4710
2 changed files with 8 additions and 7 deletions

View File

@ -211,7 +211,7 @@ ignore_tc_too_many_errors = False
# cleaned up (deleted) by the OS on boot.
# The state file is written to disk every sensor_time_wait seconds (2s by default)
# and is written in the same directory as config.py.
automatic_restarts = False
automatic_restarts = True
automatic_restart_window = 15 # max minutes since power outage
automatic_restart_state_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ),'state.json'))

View File

@ -339,12 +339,13 @@ class Oven(threading.Thread):
startat = 0
return startat
def run_profile(self, profile, startat=0):
def run_profile(self, profile, startat=0, auto_start=False):
runtime = startat * 60
if self.state == 'IDLE':
if config.seek_start:
temp = self.board.temp_sensor.temperature() # Defined in a subclass
runtime += self.get_start_from_temperature(profile, temp)
if not auto_start:
if self.state == 'IDLE':
if config.seek_start:
temp = self.board.temp_sensor.temperature() # Defined in a subclass
runtime += self.get_start_from_temperature(profile, temp)
self.reset()
self.startat = startat * 60
@ -484,7 +485,7 @@ class Oven(threading.Thread):
with open(profile_path) as infile:
profile_json = json.dumps(json.load(infile))
profile = Profile(profile_json)
self.run_profile(profile,startat=startat)
self.run_profile(profile,startat=startat, auto_start=True)
self.cost = d["cost"]
time.sleep(1)
self.ovenwatcher.record(profile)