Refactor TemperatureMonitor logging to remove sensor ID and simplify log format; update ScheduleMonitor to indicate HOLD mode when scheduling is disabled.
This commit is contained in:
parent
33e2944fd8
commit
2c10fdff62
@ -146,10 +146,6 @@ class TemperatureMonitor(Monitor):
|
|||||||
def _log_temperature(self, temp):
|
def _log_temperature(self, temp):
|
||||||
"""Log temperature to CSV file."""
|
"""Log temperature to CSV file."""
|
||||||
try:
|
try:
|
||||||
# Get sensor ID
|
|
||||||
sensor_ids = self.sensor.get_sensor_ids()
|
|
||||||
sensor_id = sensor_ids[0] if sensor_ids else "unknown"
|
|
||||||
|
|
||||||
# Get timestamp
|
# Get timestamp
|
||||||
t = time.localtime()
|
t = time.localtime()
|
||||||
timestamp = "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}".format(
|
timestamp = "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{:02d}".format(
|
||||||
@ -158,8 +154,8 @@ class TemperatureMonitor(Monitor):
|
|||||||
|
|
||||||
# Append to log file
|
# Append to log file
|
||||||
with open(self.log_file, 'a') as f:
|
with open(self.log_file, 'a') as f:
|
||||||
f.write("{},{},{},{:.2f}\n".format(
|
f.write("{},{},{:.2f}\n".format(
|
||||||
timestamp, self.label, sensor_id, temp
|
timestamp, self.label, temp
|
||||||
))
|
))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Error logging temperature: {}".format(e))
|
print("Error logging temperature: {}".format(e))
|
||||||
|
|||||||
@ -47,6 +47,7 @@ class ScheduleMonitor:
|
|||||||
def _find_active_schedule(self):
|
def _find_active_schedule(self):
|
||||||
"""Find which schedule should be active right now."""
|
"""Find which schedule should be active right now."""
|
||||||
if not self.config.get('schedule_enabled', False):
|
if not self.config.get('schedule_enabled', False):
|
||||||
|
# Schedule is disabled (HOLD mode)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
schedules = self.config.get('schedules', [])
|
schedules = self.config.get('schedules', [])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user