From 4348738b206e177d5eaf4d591709b72020d7f1fc Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 6 Nov 2019 21:41:27 +0100 Subject: [PATCH] skip ZGPSwitch --- get-sensors.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/get-sensors.py b/get-sensors.py index 4394947..a65e834 100755 --- a/get-sensors.py +++ b/get-sensors.py @@ -28,7 +28,6 @@ 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() @@ -36,7 +35,6 @@ try: token = args.token battery = args.battery verbose = args.verbose - debug = args.debug except argparse.ArgumentError as e: print(str(e)) @@ -59,6 +57,9 @@ for key in json_data: if p.search(json_data[key]['uniqueid']): if json_data[key]['type'] == 'ZLLPresence': sensors[json_data[key]['uniqueid'][:-8]].insert(0, key) + elif json_data[key]['type'] == 'ZGPSwitch': + # Don't add ZGPSwitch, doesn't have a battery component + continue else: sensors[json_data[key]['uniqueid'][:-8]].append(key) @@ -74,7 +75,7 @@ for key in sensors: print(f"{i:>5s}: {json_data.get(i)['productname']}") else: if not "battery" in json_data.get(i)['config']: - print(f"ID Failing: {i}") + print(f"Sensor without battery property found: {i}") print(json.dumps(json_data.get(i), indent=4, sort_keys=True)) quit() if int(json_data.get(i)['config']['battery']) < battery: