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: