Refactor WiFiMonitor: add notification for restored connection and improve error handling in run_monitors function
This commit is contained in:
parent
d5149cf237
commit
c1e2460758
@ -143,3 +143,19 @@ class WiFiMonitor(Monitor):
|
|||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.led.off()
|
self.led.off()
|
||||||
|
|
||||||
|
# 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}")
|
||||||
Loading…
x
Reference in New Issue
Block a user