c4fb0432ae
GitOrigin-RevId: 3fc1143a04da49a92c3663813c6a0c1e8ccd477f
39 lines
859 B
Python
39 lines
859 B
Python
#!/usr/bin/env python
|
|
|
|
import idual
|
|
import sys
|
|
|
|
def help():
|
|
print('Available commands:')
|
|
for cmd in idual.commands:
|
|
print('- ' + cmd)
|
|
sys.exit(0)
|
|
|
|
def handle(ctrl, cmd):
|
|
if cmd == 'help':
|
|
help()
|
|
elif cmd == 'wakey':
|
|
ctrl.wakey()
|
|
sys.exit(0)
|
|
elif cmd == 'on':
|
|
print('Turning on the lights')
|
|
ctrl.send_cmd(cmd)
|
|
elif cmd == 'off':
|
|
print('Turning off the lights')
|
|
ctrl.send_cmd(cmd)
|
|
elif cmd in idual.commands:
|
|
print('Sending ' + cmd + '-command')
|
|
ctrl.send_cmd(cmd)
|
|
else:
|
|
print('unknown command \'' + cmd + '\'')
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) == 1:
|
|
help()
|
|
|
|
print('Initialising light controller')
|
|
ctrl = idual.LightController()
|
|
|
|
for cmd in sys.argv[1:]:
|
|
handle(ctrl, cmd)
|