Ejemplo n.º 1
0
def set_color_hex(hex):
    """
    Sets the color of the connected light.

    :param hex: hex value of the color to set the light to
    :return: json string with success status and message
    """
    animation_thread.stop()
    animation_thread.set_color(hex='#'+hex)
    return json.dumps({'status': 'success', 'message': 'Set color to #' + hex})
Ejemplo n.º 2
0
def set_color_name(name):
    """
    Sets the color of the connected light.

    :param name: CSS name of the color to set the light to
    :return: json string with success status and message
    """
    animation_thread.stop()
    animation_thread.set_color(name=name)
    return json.dumps({'status': 'success', 'message': 'Set color to ' + name})
Ejemplo n.º 3
0
def set_color_rgb(r, g, b):
    """
    Sets the color of the connected light.

    :param r: intensity 0-255 of the red channel
    :param g: intensity 0-255 of the green channel
    :param b: intensity 0-255 of the blue channel
    :return: json string with success status and message
    """
    animation_thread.stop()
    animation_thread.set_color(red=r, green=g, blue=b)
    message = 'Set color to rgb %d, %d, %d' % (r, g, b)
    return json.dumps({'status': 'success', 'message': message})