From b93809946a922eef4daa481cb585ee0ab561d5ed Mon Sep 17 00:00:00 2001 From: sickprodigy Date: Sat, 8 Nov 2025 15:48:00 -0500 Subject: [PATCH] feat: Add caching for last temperature reading in TemperatureMonitor --- Scripts/monitors.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Scripts/monitors.py b/Scripts/monitors.py index 5277dc4..9795345 100644 --- a/Scripts/monitors.py +++ b/Scripts/monitors.py @@ -55,6 +55,8 @@ class TemperatureMonitor(Monitor): self.last_report = 0 self.alert_sent = False self.alert_start_time = None # Track when alert started + self.last_temp = None # Cached Last temperature reading + self.last_read_time = 0 # Timestamp of last reading def should_run(self): """Check if it's time to run this monitor.""" @@ -75,6 +77,10 @@ class TemperatureMonitor(Monitor): temp = list(temps.values())[0] # Get first temp reading + # Cache the reading for web server (avoid blocking reads) + self.last_temp = temp + self.last_read_time = current_time + # Check for alerts alert_condition = False alert_message = ""