From c1e2460758a42e0aad7e09671f1aaceb64c61c2a Mon Sep 17 00:00:00 2001 From: sickprodigy Date: Tue, 4 Nov 2025 22:01:27 -0500 Subject: [PATCH] Refactor WiFiMonitor: add notification for restored connection and improve error handling in run_monitors function --- Scripts/monitors.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Scripts/monitors.py b/Scripts/monitors.py index 0527b8b..e15b12d 100644 --- a/Scripts/monitors.py +++ b/Scripts/monitors.py @@ -142,4 +142,20 @@ class WiFiMonitor(Monitor): self.led.on() time.sleep(1) self.led.off() - \ No newline at end of file + + # Notify if connection was just restored + if not self.was_connected: + send_discord_message("WiFi connection restored 🔄") + self.was_connected = True + +def run_monitors(monitors): + """ + Run all monitors in the list, checking if each should run based on interval. + Call this in your main loop. + """ + for monitor in monitors: + if monitor.should_run(): + try: + monitor.run() + except Exception as e: + print(f"Error running monitor {monitor.__class__.__name__}: {e}") \ No newline at end of file