Beispiel #1
0
def animation_stop():
    """
    Stops the current animation
    :return: json string with success status and message
    """
    animation_thread.stop()
    message = 'Animations stopped'
    return json.dumps({'status': 'success', 'message': message})
Beispiel #2
0
def turn_off():
    """
    Switches the light off
    :return: json string with success status and message
    """
    animation_thread.stop()
    animation_thread.turn_off()
    message = 'Turned light off'
    return json.dumps({'status': 'success', 'message': message})
Beispiel #3
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})
Beispiel #4
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})
Beispiel #5
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})