summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2016-07-19 08:21:20 +1200
committerFlorian Baumann <derflob@derflob.de>2016-07-19 08:21:20 +1200
commit53ed2ebac8234609ab3e7a4cd02aab3b1d1fbf2c (patch)
tree443cbe17cdffab961d942fc2cd4cb24329627981
parent297264578292a98c7e6daa4c62514050a6784143 (diff)
downloadxmpp-all_systems.tar.gz
xmpp-all_systems.tar.bz2
add --reapeat & --delay args to rcswitch.pyall_systems
-rw-r--r--rcswitch.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/rcswitch.py b/rcswitch.py
index b51c2ab..308a07a 100644
--- a/rcswitch.py
+++ b/rcswitch.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import pi_switch
import argparse
+from time import sleep
if (__name__ == "__main__"):
parser = argparse.ArgumentParser()
@@ -11,12 +12,19 @@ if (__name__ == "__main__"):
action.add_argument('--on', action='store_true')
action.add_argument('--off', action='store_true')
+ parser.add_argument('--repeat', type=int, default=3)
+ parser.add_argument('--delay', type=int, default=100)
+
args = parser.parse_args()
sw = pi_switch.RCSwitchA(args.channel, args.group)
sw.enableTransmit(0)
- if (args.on):
- sw.switchOn()
- elif (args.off):
- sw.switchOff()
- else:
- sw.switchOff()
+ for i in range(args.repeat):
+ if (args.on):
+ sw.switchOn()
+ elif (args.off):
+ sw.switchOff()
+ else:
+ sw.switchOff()
+
+ if ((i+1) < args.repeat):
+ sleep(args.delay/1000.0)