adding check for battery bug
This commit is contained in:
parent
1dd8b4e202
commit
5883ed9570
5
get-sensors.py
Executable file → Normal file
5
get-sensors.py
Executable file → Normal file
@ -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']}%")
|
||||
|
Loading…
Reference in New Issue
Block a user