summaryrefslogtreecommitdiff
path: root/mqtt-notify.py
AgeCommit message (Collapse)Author
2 daysmqtt-notify: Recover from lost connectionsHEADmasterMatt Turner
The service runs for as long as the session does, so it has to survive laptop suspends and network changes. It did not: a connection that died while the machine was asleep could leave the client wedged, with no way back short of restarting the unit by hand. Tighten the reconnect behavior and add a way out when it still fails: - Bound paho's reconnect backoff to 30 seconds. The default grows to two minutes between attempts, so even a successful reconnect could take minutes to happen. - Drop the keepalive from 60 to 30 seconds so that a connection which went away without a FIN is noticed sooner. - Track how long we have been disconnected and exit if that exceeds two minutes, and set Restart=always in the unit file so that systemd brings us back with a fresh client. CLOCK_MONOTONIC excludes time spent suspended, so this does not fire spuriously on resume. Also stop calling sys.exit() from on_message(). It runs on paho's network thread, where SystemExit only kills that thread and leaves the main loop running with no connection. Quit the main loop instead.
2024-05-16mqtt-notify.py: Make compatible with paho-mqtt v2Matt Turner
2024-05-16mqtt-notify.py: Run blackMatt Turner
2024-05-16mqtt-notify.py: Exit if message fails to showMatt Turner
2020-10-14mqtt-notify.py: Switch to synchronous Secret.password_lookup_sync()Matt Turner
Using the asynchronous function caused multiple password dialogs to appear.
2020-10-03mqtt-notify.py: Use asynchronous Secret.password_lookup()Matt Turner
2020-10-03mqtt-notify.py: Use walrus operatorMatt Turner
2019-10-09Initial importMatt Turner