示例#1
0
def disable():
    socket = request.args.get('value')
    if socket == 'all':
        for socket in range(1, 9):
            relay_ctl.turnoff(str(socket))
        state = relay_ctl.state()
        return json.dumps(state)
    elif socket in validSocket[:-1]:
        relay_ctl.turnoff(socket)
        state = relay_ctl.state()
        return json.dumps(state)
    else:
        print "Invalid Request: invalid socket, valid sockets: " + ' '.join(
            validSocket)
        return json.dumps({"error": "invalid socket"})
示例#2
0
def state():
    socket = request.args.get('value')
    state = relay_ctl.state()
    if socket == 'all' or socket == None:
        return json.dumps(state)
    elif socket in validSocket[:-1]:
        return json.dumps({socket: state[socket]})
    else:
        print "Invalid Request: invalid socket, valid sockets: " + ' '.join(
            validSocket)
        return json.dumps({"error": "invalid socket"})
示例#3
0
def reset():
    relay_ctl.reset()
    state = relay_ctl.state()
    return json.dumps(state)