From 21d96bd140359a3b360bd728b963effc6b747c4f Mon Sep 17 00:00:00 2001 From: Marcin Koperski Date: Sun, 18 Mar 2018 22:55:03 +0100 Subject: [PATCH] Add option to switch state (#160) Find lacking for an option in one line to switch a state of SP2 switches --- cli/broadlink_cli | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cli/broadlink_cli b/cli/broadlink_cli index 097a7afbd..8d055f701 100755 --- a/cli/broadlink_cli +++ b/cli/broadlink_cli @@ -71,6 +71,7 @@ parser.add_argument("--temperature",action="store_true", help="request temperatu 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("--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("--sensors", action="store_true", help="check all sensors") parser.add_argument("--learn", action="store_true", help="learn command") @@ -150,3 +151,10 @@ if args.turnoff: print '!! Still ON !!' else: print '== Turned * OFF * ==' +if args.switch: + if dev.check_power(): + dev.set_power(False) + print '* Switch to OFF *' + else: + dev.set_power(True) + print '* Switch to ON *'