From 84e171dbdb51955599c814e909b8cbafc8c7bdd9 Mon Sep 17 00:00:00 2001 From: mischa Date: Wed, 6 Nov 2019 21:28:21 +0100 Subject: [PATCH] adding check for battery bug --- get-sensors.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 get-sensors.py diff --git a/get-sensors.py b/get-sensors.py old mode 100644 new mode 100755 index bc10628..460b0d5 --- a/get-sensors.py +++ b/get-sensors.py @@ -55,7 +55,7 @@ p = re.compile("([a-fA-F0-9]{2}:?){8}") sensors = collections.defaultdict(list); for key in json_data: - if "uniqueid" in json_data[key] and json_data[key]['state']: + if "uniqueid" in json_data[key] and json_data[key]['state']['presence']: if p.search(json_data[key]['uniqueid']): if json_data[key]['type'] == 'ZLLPresence': sensors[json_data[key]['uniqueid'][:-8]].insert(0, key) @@ -74,6 +74,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(json.dumps(json_data.get(i), indent=4, sort_keys=True)) quit() if int(json_data.get(i)['config']['battery']) < battery: