From 5883ed957047a5270dd4ed4058db5788fc04105a Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 6 Nov 2019 21:18:30 +0100 Subject: [PATCH] adding check for battery bug --- get-sensors.py | 5 +++++ 1 file changed, 5 insertions(+) mode change 100755 => 100644 get-sensors.py diff --git a/get-sensors.py b/get-sensors.py old mode 100755 new mode 100644 index 35eb1af..80880a9 --- a/get-sensors.py +++ b/get-sensors.py @@ -28,6 +28,7 @@ parser.add_argument("bridge", type=str, help="Hue Bridge IP") parser.add_argument("token", type=str, help="Hue API Token") parser.add_argument("-b", "--battery", type=int, help="battery check only, threshold, default 20") parser.add_argument("-v", "--verbose", action='store_true', help="verbose") +parser.add_argument("-d", "--debug", action='store_true', help="debug") try: args = parser.parse_args() @@ -35,6 +36,7 @@ try: token = args.token battery = args.battery verbose = args.verbose + debug = args.debug except argparse.ArgumentError as e: print(str(e)) @@ -71,6 +73,9 @@ for key in sensors: if json_data.get(i)['type'] == 'ZLLTemperature': print(f"{i:>5s}: {json_data.get(i)['productname']}") else: + if not "battery" in json_data.get(i)['config']: + print(json.dumps(json_data.get(i), indent=4, sort_keys=True)) + quit() if int(json_data.get(i)['config']['battery']) < battery: if json_data.get(i)['type'] == 'ZLLPresence': print(f"{json_data.get(i)['name']:<32s} battery level {json_data.get(i)['config']['battery']}%")