summaryrefslogtreecommitdiffstats
path: root/drcontrol.py
diff options
context:
space:
mode:
authorsebastian.sjoholm <sebastian.sjoholm@gmail.com>2013-01-09 19:17:23 +0000
committersebastian.sjoholm <sebastian.sjoholm@gmail.com>2013-01-09 19:17:23 +0000
commit3b10782fcc40702a6e699629efd98db179773d60 (patch)
tree37b9ce1e2aa1000a2c31145a8dbe0dc4fd1e9487 /drcontrol.py
parent2ed9b6e06d389ef3781dcc8a15ed59ad29b4687e (diff)
downloaddrcontrol-3b10782fcc40702a6e699629efd98db179773d60.zip
drcontrol-3b10782fcc40702a6e699629efd98db179773d60.tar.gz
Fix with "all"
Diffstat (limited to 'drcontrol.py')
-rwxr-xr-xdrcontrol.py48
1 files changed, 25 insertions, 23 deletions
diff --git a/drcontrol.py b/drcontrol.py
index ba8a1e6..5618d41 100755
--- a/drcontrol.py
+++ b/drcontrol.py
@@ -146,33 +146,35 @@ def set_relay():
with BitBangDevice(cmdarg.device) as bb:
# Action towards specific relay
- if int(cmdarg.relay) >= 1 and int(cmdarg.relay) <= 8:
+ if cmdarg.relay.isdigit():
+
+ if int(cmdarg.relay) >= 1 and int(cmdarg.relay) <= 8:
- # Turn relay ON
- if cmdarg.command == "on":
- if cmdarg.verbose:
- print "Relay " + str(cmdarg.relay) + " to ON"
- bb.port |= int(relay.address[cmdarg.relay], 16)
-
- # Turn relay OFF
- elif cmdarg.command == "off":
- if cmdarg.verbose:
- print "Relay " + str(cmdarg.relay) + " to OFF"
- bb.port &= ~int(relay.address[cmdarg.relay], 16)
-
- # Print relay status
- elif cmdarg.command == "state":
- state = get_relay_state( bb.port, cmdarg.relay )
- if state == 0:
+ # Turn relay ON
+ if cmdarg.command == "on":
if cmdarg.verbose:
- print "Relay " + cmdarg.relay + " state:\tOFF (" + str(state) + ")"
- else:
- print "OFF"
- else:
+ print "Relay " + str(cmdarg.relay) + " to ON"
+ bb.port |= int(relay.address[cmdarg.relay], 16)
+
+ # Turn relay OFF
+ elif cmdarg.command == "off":
if cmdarg.verbose:
- print "Relay " + cmdarg.relay + " state:\tON (" + str(state) + ")"
+ print "Relay " + str(cmdarg.relay) + " to OFF"
+ bb.port &= ~int(relay.address[cmdarg.relay], 16)
+
+ # Print relay status
+ elif cmdarg.command == "state":
+ state = get_relay_state( bb.port, cmdarg.relay )
+ if state == 0:
+ if cmdarg.verbose:
+ print "Relay " + cmdarg.relay + " state:\tOFF (" + str(state) + ")"
+ else:
+ print "OFF"
else:
- print "ON"
+ if cmdarg.verbose:
+ print "Relay " + cmdarg.relay + " state:\tON (" + str(state) + ")"
+ else:
+ print "ON"
# Action towards all relays
elif cmdarg.relay == "all":
OpenPOWER on IntegriCloud