From 26c0fde7fa957a1231ab8e7990a39678466895f0 Mon Sep 17 00:00:00 2001 From: Thomas Dietrich Date: Sun, 30 Jul 2017 15:27:08 +0200 Subject: [PATCH] Add python2 detection for the poor, bugfix --- miflora-mqtt-daemon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/miflora-mqtt-daemon.py b/miflora-mqtt-daemon.py index 118052c..e357dea 100755 --- a/miflora-mqtt-daemon.py +++ b/miflora-mqtt-daemon.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 -import re import sys +import re import json import os.path from time import sleep, localtime, strftime @@ -17,6 +17,9 @@ print('Xiaomi Mi Flora Plant Sensor MQTT Client/Daemon') print('Source: https://github.com/ThomDietrich/miflora-mqtt-daemon') print() +if False: + print('Sorry, this script requires a python3 runtime environemt.', file=sys.stderr) + # Systemd Service Notifications - https://github.com/bb4242/sdnotify sd_notifier = sdnotify.SystemdNotifier() @@ -176,6 +179,7 @@ while True: while retries > 0 and not flora['poller']._cache: try: flora['poller'].fill_cache() + flora['poller'].parameter_value(MI_LIGHT) except IOError: print('Failed to retrieve data from Mi Flora Sensor "{}" ({}). Retrying ...'.format(flora_name, flora['mac']), file=sys.stderr) sd_notifier.notify('STATUS=Failed to retrieve data from Mi Flora Sensor "{}" ({}). Retrying ...'.format(flora_name, flora['mac']))