forked from richbeales/python-orvibo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmd.py
More file actions
20 lines (17 loc) · 725 Bytes
/
cmd.py
File metadata and controls
20 lines (17 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from orvibo.s20 import S20
import argparse
parser = argparse.ArgumentParser(description='Control the S20 switch.')
parser.add_argument('--server', dest='server', type=str, help='the IP address of the switch to control')
parser.add_argument('--switch', dest='operation', help='what to do (ON or OFF)')
parser.add_argument('--status', dest='status', help='the current switch state', action="store_true")
args = parser.parse_args()
s20 = S20(args.server)
if args.status:
print("ON" if s20.on else "OFF")
else:
if args.operation and args.operation.upper() == 'ON':
s20.on = True
elif args.operation and args.operation.upper() == 'OFF':
s20.on = False
else:
print("unrecognised command")