def handle(self, handler_input): # type: (HandlerInput) -> Response logger.info("In TurnOnFavoriteColorHandler") attr = handler_input.attributes_manager.session_attributes favorite_color = attr.get("favorite_color", "") response_builder = handler_input.response_builder if favorite_color is not "": command = favorite_color + "_light_on" logger.info(command) util.iot_command(command) rsp = random.choice(data.TURNING_FAVORITE_LIGHT_ON) response_builder = handler_input.response_builder response_builder.speak(rsp) response_builder.ask(rsp) else: rsp = random.choice(data.UNDEFINED_FAVORITE_LIGHT) attr["state"] = "waiting_define_favorite_color" response_builder = handler_input.response_builder response_builder.speak(rsp) response_builder.ask(rsp) return response_builder.response
def handle(self, handler_input): # type: (HandlerInput) -> Response logger.info("In LightOffHandler") attr = handler_input.attributes_manager.session_attributes light_slot = util.get_slots(handler_input.request_envelope.request.intent.slots)[0] command = data.COLORS[light_slot] + "_light_off" logger.info(command) util.iot_command(command) rsp = random.choice(data.TURNING_LIGHT_OFF) + light_slot + "." response_builder = handler_input.response_builder response_builder.speak(rsp) response_builder.ask(rsp) return response_builder.response
def handle(self, handler_input): # type: (HandlerInput) -> Response logger.info("In LightsOffHandler") attr = handler_input.attributes_manager.session_attributes lights_str = "" light_slots = util.get_slots(handler_input.request_envelope.request.intent.slots) count = 1 for light_slot in light_slots: command = data.COLORS[light_slot] + "_light_of" logger.info(command) util.iot_command(command) lights_str += light_slot + (", " if count < len(light_slots) - 1 else (" e " if count < len(light_slots) else ".")) count += 1 rsp = random.choice(data.TURNING_LIGHT_OFF) + lights_str response_builder = handler_input.response_builder response_builder.speak(rsp) response_builder.ask(rsp) return response_builder.response
def handle(self, handler_input): # type: (HandlerInput) -> Response logger.info("In AllLightsOffHandler") attr = handler_input.attributes_manager.session_attributes util.iot_command("red_light_off") util.iot_command("green_light_off") util.iot_command("yellow_light_off") rsp = random.choice(data.TURNING_ALL_LIGHTS_OFF) response_builder = handler_input.response_builder response_builder.speak(rsp) response_builder.ask(rsp) return response_builder.response