about summary refs log tree commit diff
path: root/cli/broadlink_cli
diff options
context:
space:
mode:
authorMarcin Koperski <IlfirinPL@users.noreply.github.com>2018-03-18T21·55+0100
committerMatthew Garrett <mjg59-github@srcf.ucam.org>2018-03-18T21·55-0700
commit21d96bd140359a3b360bd728b963effc6b747c4f (patch)
tree1fc3a340a2c2dfb3e173f3552980204a08f72510 /cli/broadlink_cli
parent26109aac67dc39b1c4dff3d1e971d463fe221847 (diff)
Add option to switch state (#160)
Find lacking for an option in one line to switch a state of SP2 switches
Diffstat (limited to 'cli/broadlink_cli')
-rwxr-xr-xcli/broadlink_cli8
1 files changed, 8 insertions, 0 deletions
diff --git a/cli/broadlink_cli b/cli/broadlink_cli
index 097a7afbdae7..8d055f7019b8 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 *'