mirror of
https://github.com/mjg59/python-broadlink.git
synced 2024-11-22 07:00:12 +01:00
Print sensors and in json format
--sensorsJson argument to check all sensors and print in json format
This commit is contained in:
parent
2a537b6112
commit
d15bf85228
@ -82,6 +82,7 @@ parser.add_argument("--turnnloff", action="store_true", help="turn off nightligh
|
|||||||
parser.add_argument("--switch", action="store_true", help="switch state from on to off and off to on")
|
parser.add_argument("--switch", action="store_true", help="switch state from on to off and off to on")
|
||||||
parser.add_argument("--send", action="store_true", help="send command")
|
parser.add_argument("--send", action="store_true", help="send command")
|
||||||
parser.add_argument("--sensors", action="store_true", help="check all sensors")
|
parser.add_argument("--sensors", action="store_true", help="check all sensors")
|
||||||
|
parser.add_argument("--sensorsJson", action="store_true", help="check all sensors and print in json format")
|
||||||
parser.add_argument("--learn", action="store_true", help="learn command")
|
parser.add_argument("--learn", action="store_true", help="learn command")
|
||||||
parser.add_argument("--rfscanlearn", action="store_true", help="rf scan learning")
|
parser.add_argument("--rfscanlearn", action="store_true", help="rf scan learning")
|
||||||
parser.add_argument("--learnfile", help="save learned command to a specified file")
|
parser.add_argument("--learnfile", help="save learned command to a specified file")
|
||||||
@ -123,6 +124,16 @@ if args.sensors:
|
|||||||
data = dev.check_sensors()
|
data = dev.check_sensors()
|
||||||
for key in data:
|
for key in data:
|
||||||
print("{} {}".format(key, data[key]))
|
print("{} {}".format(key, data[key]))
|
||||||
|
if args.sensorsJson:
|
||||||
|
data = dev.check_sensors()
|
||||||
|
print("{")
|
||||||
|
ftt = True
|
||||||
|
for key in data:
|
||||||
|
if not ftt:
|
||||||
|
print(",")
|
||||||
|
print(" \"{}\" : {}".format(key, data[key]))
|
||||||
|
ftt = False
|
||||||
|
print("}")
|
||||||
if args.send:
|
if args.send:
|
||||||
data = durations_to_broadlink(parse_durations(' '.join(args.data))) \
|
data = durations_to_broadlink(parse_durations(' '.join(args.data))) \
|
||||||
if args.durations else bytearray.fromhex(''.join(args.data))
|
if args.durations else bytearray.fromhex(''.join(args.data))
|
||||||
|
Loading…
Reference in New Issue
Block a user