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})
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})
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})
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})
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})