From 8597dd94f589292806124239f031ab564a71bc3a Mon Sep 17 00:00:00 2001 From: Daniel Chesterton Date: Sat, 13 Feb 2021 15:04:02 +0000 Subject: [PATCH] Log warning if unable to fetch storage sensors --- src/amcrest2mqtt.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/amcrest2mqtt.py b/src/amcrest2mqtt.py index 2bbc90b..28f2153 100644 --- a/src/amcrest2mqtt.py +++ b/src/amcrest2mqtt.py @@ -88,11 +88,13 @@ def refresh_storage_sensors(): Timer(storage_sensors_interval, refresh_storage_sensors).start() log("Fetching storage sensors...") - storage = camera.storage_all - mqtt_publish(topics["storage_used_percent"], str(storage["used_percent"])) - mqtt_publish(topics["storage_used"], str(storage["used"][0])) - mqtt_publish(topics["storage_total"], str(storage["total"][0])) - + try: + storage = camera.storage_all + mqtt_publish(topics["storage_used_percent"], str(storage["used_percent"])) + mqtt_publish(topics["storage_used"], str(storage["used"][0])) + mqtt_publish(topics["storage_total"], str(storage["total"][0])) + except AmcrestError as error: + log(f"Error fetching storage information {error}", level="WARNING") def signal_handler(sig, frame): # exit immediately upon receiving a second SIGINT