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:57:34 +1200
commit5e41a33cdb4853996f8dc62f5e474fcebda4427f (patch)
tree443cbe17cdffab961d942fc2cd4cb24329627981
parent92f10603b84ed68437a9d107498fed859b1cff85 (diff)
downloadxmpp-5e41a33cdb4853996f8dc62f5e474fcebda4427f.tar.gz
xmpp-5e41a33cdb4853996f8dc62f5e474fcebda4427f.tar.bz2
add --reapeat & --delay args to rcswitch.py
-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)