def party():
if not is_local_request(flask.request):
flask.abort(404)
global party_process
json = flask.request.get_json()
enabled = json.get('enabled', False)
logger.info('Got party state %r' % enabled)
if enabled and not env.is_party_mode():
# Start party XD
party_process = Popen(["python3", "./animate_web.py", "run"]) # async
env.set_party_mode(True)
env.set_motion_enabled(False)
elif not enabled and env.is_party_mode():
# Stop party :(
env.set_party_mode(False)
env.set_motion_enabled(True)
if party_process is not None:
party_process.kill()
party_process = None
# Return lights to circadian color
command = copy.deepcopy(COMMAND_FULL_ON)
circadian_color = get_current_circadian_color(date=get_local_time())
command_all_lights(circadian_color.apply_to_command(command))
return "Party mode is now %r" % enabled
评论列表
文章目录