Exemplo n.º 1
0
def off():
    for light in all_the_lights:
        if (int(light) == id1) or (int(light) == id2):
            url_to_call = lights_URL + light + '/state'
            body = '{ "on" : false}'
            service.send('PUT', url_to_call, body,
                         {'Content-Type': 'application/json'})
    return 1
Exemplo n.º 2
0
def init():
    global all_the_lights
    all_the_lights = service.send(url=lights_URL)
    for light in all_the_lights:
        if (int(light) == id1) or (int(light) == id2):
            url_to_call = lights_URL + light + '/state'
            body = '{ "on" : true, "hue": 0, "sat" : 254, "bri": 0, "effect" : "none" }'
            service.send('PUT', url_to_call, body,
                         {'Content-Type': 'application/json'})
Exemplo n.º 3
0
def dance():
    global LOOP
    LOOP = True
    for light in all_the_lights:
        if (int(light) == id1) or (int(light) == id2):
            url_to_call = lights_URL + light + '/state'
            body = '{ "on" : true, "hue": 12750,"bri": 254, "effect" : "colorloop" }'
            service.send('PUT', url_to_call, body,
                         {'Content-Type': 'application/json'})
    return 1
Exemplo n.º 4
0
def wrong():
    global LOOP
    if LOOP:
        init()
        LOOP = False
    for light in all_the_lights:
        if (int(light) == id1) or (int(light) == id2):
            url_to_call = lights_URL + light + '/state'
            body = '{ "on" : true, "hue": 0 ,"bri": 254, "effect" : "none"}'
            service.send('PUT', url_to_call, body,
                         {'Content-Type': 'application/json'})
    return 1