feat: Add temperature validation in TemperatureMonitor and implement aggressive garbage collection in main loop

This commit is contained in:
2025-11-09 11:54:12 -05:00
parent dae6971112
commit 229bde85e9
3 changed files with 18 additions and 16 deletions

View File

@@ -77,6 +77,12 @@ class TemperatureMonitor(Monitor):
temp = list(temps.values())[0] # Get first temp reading
# ===== ADD THIS: Validate temperature is reasonable =====
if temp < -50 or temp > 150: # Sanity check (outside normal range)
print("⚠️ Warning: {} sensor returned invalid temp: {:.1f}°F".format(self.label, temp))
return # Don't cache invalid reading
# ===== END: Validation =====
# Cache the reading for web server (avoid blocking reads)
self.last_temp = temp
self.last_read_time = current_time