def launch_request(session, user, request): if not nest.isValidUser(user.getUserId()): output_speech = "Current user is not a valid nest user. Please look at the Echo app for help" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = ( "Current user is not a valid nest user. Please authenticate user with userId: " + user.getUserId() + " to Nest as instructed in the README" ) response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } return response else: output_speech = "Welcome to Nest Control App. Please say a command." output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Welcome" card_content = "Welcome to Nest Control App. Please say a command." response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": False, } return response
def launch_request(session, user, request): if not nest.isValidUser(user.getUserId()): output_speech = "Current user is not a valid nest user. Please look at the Echo app for help" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + user.getUserId( ) + " to Nest as instructed in the README" response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': True } return response else: output_speech = "Welcome to Nest Control App. Please say a command." output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Welcome" card_content = "Welcome to Nest Control App. Please say a command." response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': False } return response
def intent_request(session, user, request): print "intent_request" if not nest.isValidUser(user.getUserId()): output_speech = "Current user is not a valid nest user. Please look at the Echo app for help" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = ( "Current user is not a valid nest user. Please authenticate user with userId: " + user.getUserId() + " to Nest as instructed in the README" ) response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } return response else: if request["intent"]["name"] == "NestSetTempIntent": nestTempValue = request["intent"]["slots"]["temp"]["value"] output_speech = "Setting Nest to " + str(nestTempValue) + " degrees fahrenheit" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + str(nestTempValue) + " degrees fahrenheit." response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } if int(nestTempValue) <= 90: nest.setTemperatureTargetAll(user.getUserId(), int(nestTempValue)) return response elif request["intent"]["name"] == "NestCoolDownIntent": setTemp = nest.setTurnDownTemperatureAll(user.getUserId()) output_speech = "Turning down the Nest" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + "str(setTemp+2)" + " degrees fahrenheit." response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } return response elif request["intent"]["name"] == "NestWarmUpIntent": setTemp = nest.setTurnUpTemperatureAll(user.getUserId()) output_speech = "Turning up the Nest" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + "str(setTemp+2)" + " degrees fahrenheit." response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } return response elif request["intent"]["name"] == "NestInquireIntent": nestTemp = nest.getAvgTemp(user.getUserId()) nestTargetTemp = nest.getAvgTargetTemp(user.getUserId()) output_speech = "Current Nest temperature is " + str(nestTemp) + " degrees fahrenheit." output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Current Nest Temp" card_content = ( "Current temperature is " + str(nestTemp) + " degrees Fahrenheit, Nest target temperature is " + str(nestTargetTemp) + " degrees Fahrenheit" ) response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": True, } return response elif request["intent"]["name"] == "HelpIntent": output_speech = "This is the Nest control app. You can tell me to set temperature to 74 degrees fahrenheit. You can also say that you are too hot or too cold and I will adjust the temperature by two degrees." output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Help" card_content = "This is the Nest control app. You can tell me to set temperature to 74 degrees. You can also say that you are too hot or too cold and I will adjust the temperature by two degrees." response = { "outputSpeech": {"type": output_type, "text": output_speech}, "card": {"type": card_type, "title": card_title, "content": card_content}, "shouldEndSession": False, } return response else: return launch_request(session, user, request) ##Just do the same thing as launch request
def intent_request(session, user, request): print "intent_request" if not nest.isValidUser(user.getUserId()): output_speech = "Current user is not a valid nest user. Please look at the Echo app for help" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + user.getUserId( ) + " to Nest as instructed in the README" response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': True } return response else: if request['intent']['name'] == "NestSetTempIntent": nestTempValue = request['intent']['slots']['temp']['value'] output_speech = "Setting Nest to " + str( nestTempValue) + " degrees fahrenheit" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + str( nestTempValue) + " degrees fahrenheit." response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': True } if int(nestTempValue) <= 90: nest.setTemperatureTargetAll(user.getUserId(), int(nestTempValue)) return response elif request['intent']['name'] == "NestCoolDownIntent": setTemp = nest.setTurnDownTemperatureAll(user.getUserId()) output_speech = "Turning down the Nest" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + "str(setTemp+2)" + " degrees fahrenheit." response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': True } return response elif request['intent']['name'] == "NestWarmUpIntent": setTemp = nest.setTurnUpTemperatureAll(user.getUserId()) output_speech = "Turning up the Nest" output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Setting Nest Temp" card_content = "Telling Nest to set to " + "str(setTemp+2)" + " degrees fahrenheit." response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': True } return response elif request['intent']['name'] == "HelpIntent": output_speech = "This is the Nest control app. You can tell me to set temperature to 74 degrees fahrenheit. You can also say that you are too hot or too cold and I will adjust the temperature by two degrees." output_type = "PlainText" card_type = "Simple" card_title = "Nest Control - Help" card_content = "This is the Nest control app. You can tell me to set temperature to 74 degrees. You can also say that you are too hot or too cold and I will adjust the temperature by two degrees." response = { "outputSpeech": { "type": output_type, "text": output_speech }, "card": { "type": card_type, "title": card_title, "content": card_content }, 'shouldEndSession': False } return response else: return launch_request( session, user, request) ##Just do the same thing as launch request