diff options
author | Valter Vicente <vallovic@gmail.com> | 2017-12-25T00·35+0000 |
---|---|---|
committer | Matthew Garrett <mjg59-github@srcf.ucam.org> | 2017-12-25T00·35+0000 |
commit | dd0e9083172d1ee54eec167d342edb3b157aea4c (patch) | |
tree | 531f682a2751cb98fada1d1903f2ac222258463c /cli/broadlink_cli | |
parent | 82172f54ab722fb9de998d0ae4c24337e41d5787 (diff) |
New flags: check power state and turn device on & off (#132)
Added new flags so it is possible to check device's current power state and to turn device on & off from CLI
Diffstat (limited to 'cli/broadlink_cli')
-rwxr-xr-x | cli/broadlink_cli | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cli/broadlink_cli b/cli/broadlink_cli index e9e63d5718aa..097a7afbdae7 100755 --- a/cli/broadlink_cli +++ b/cli/broadlink_cli @@ -68,6 +68,9 @@ parser.add_argument("--type", type=auto_int, default=0x2712, help="type of devic parser.add_argument("--host", help="host address") parser.add_argument("--mac", help="mac address (hex reverse), as used by python-broadlink library") parser.add_argument("--temperature",action="store_true", help="request temperature from device") +parser.add_argument("--check", action="store_true", help="check current power state") +parser.add_argument("--turnon", action="store_true", help="turn on device") +parser.add_argument("--turnoff", action="store_true", help="turn off device") parser.add_argument("--send", action="store_true", help="send command") parser.add_argument("--sensors", action="store_true", help="check all sensors") parser.add_argument("--learn", action="store_true", help="learn command") @@ -130,3 +133,20 @@ if args.learn or args.learnfile: text_file.write(learned) else: print "No data received..." +if args.check: + if dev.check_power(): + print '* ON *' + else: + print '* OFF *' +if args.turnon: + dev.set_power(True) + if dev.check_power(): + print '== Turned * ON * ==' + else: + print '!! Still OFF !!' +if args.turnoff: + dev.set_power(False) + if dev.check_power(): + print '!! Still ON !!' + else: + print '== Turned * OFF * ==' |