diff --git a/config.py b/config.py index 372235b..f541123 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ import logging +import os # uncomment this if using MAX-31856 #from lib.max31856 import MAX31856 @@ -160,6 +161,9 @@ ignore_emergencies = False # automatically on boot-up for this to work. # DO NOT put automatic_restart_state_file anywhere in /tmp. It could be # 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 = True automatic_restart_window = 15 # max minutes since power outage -automatic_restart_state_file = "/home/jason/repos/kiln-controller/state/kiln_controller_state.json" +automatic_restart_state_file = os.path.abspath(os.path.join(os.path.dirname( __file__ ),'state.json')) + diff --git a/lib/oven.py b/lib/oven.py index d98b536..c1c7d8e 100644 --- a/lib/oven.py +++ b/lib/oven.py @@ -328,7 +328,8 @@ class Oven(threading.Thread): if not config.automatic_restarts == True: return False if self.state_file_is_old(): - log.info("restart not possible. state file too old.") + # this log statement is too noisy. + #log.info("restart not possible. state file too old.") return False if os.path.isfile(config.automatic_restart_state_file): with open(config.automatic_restart_state_file) as infile: d = json.load(infile) @@ -352,6 +353,7 @@ class Oven(threading.Thread): profile_json = json.dumps(json.load(infile)) profile = Profile(profile_json) self.run_profile(profile,startat=startat) + time.sleep(1) self.ovenwatcher.record(profile) def set_ovenwatcher(self,watcher):