From dd0e9083172d1ee54eec167d342edb3b157aea4c Mon Sep 17 00:00:00 2001 From: Valter Vicente Date: Mon, 25 Dec 2017 00:35:09 +0000 Subject: [PATCH] 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 --- cli/broadlink_cli | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cli/broadlink_cli b/cli/broadlink_cli index e9e63d571..097a7afbd 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 * =='