Exemplo n.º 1
0
def launch_request(session, userId, request):
	if not nest.isValidNestUser(userId):
		alexaId = genNewAlexaId(userId,10)
		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 - Setup"
		card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + alexaId + " to Nest as instructed on the website"

		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
Exemplo n.º 2
0
def launch_request(session, userId, request):
    if not nest.isValidNestUser(userId):
        alexaId = genNewAlexaId(userId, 10)
        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 - Setup"
        card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + alexaId + " to Nest as instructed on the website"

        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
Exemplo n.º 3
0
def intent_request(session, userId, request):
    print "intent_request"
    print request

    if not nest.isValidNestUser(userId):
        alexaId = genNewAlexaId(userId, 10)
        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 - Setup"
        card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + alexaId + " to Nest as instructed on the website"

        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
            }

            print nestTempValue
            if int(nestTempValue) <= 90:
                nest.setTemperatureTargetAll(userId, int(nestTempValue))

                return response
            else:
                return nest.generateError('Temperature out of range',
                                          'Set Temp')

        elif request['intent']['name'] == "NestSetTempOneIntent":
            nestTempValue = request['intent']['slots']['temp']['value']
            nestThermoName = request['intent']['slots']['thermo']['value']

            output_speech = "Setting " + str(nestThermoName) + " 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
            }

            print nestTempValue
            if int(nestTempValue) <= 90:
                nest.setTemperatureTargetOne(userId, int(nestTempValue),
                                             str(nestThermoName))

                return response
            else:
                return nest.generateError('Temperature out of range',
                                          'Set Temp')

        elif request['intent']['name'] == "NestCoolDownIntent":
            setTemp = nest.setTurnDownTemperatureAll(userId)
            if setTemp is not False:
                output_speech = "Turning down the Nest to an average temperature of " + str(
                    setTemp) + " degrees."
                output_type = "PlainText"

                card_type = "Simple"
                card_title = "Nest Control - Setting Nest Temp"
                card_content = "Telling Nest to set to " + str(
                    setTemp) + " degrees fahrenheit."

                response = {
                    "outputSpeech": {
                        "type": output_type,
                        "text": output_speech
                    },
                    "card": {
                        "type": card_type,
                        "title": card_title,
                        "content": card_content
                    },
                    'shouldEndSession': True
                }

                return response
            else:
                return nest.generateError('Unknown Error', 'Cool Down')

        elif request['intent']['name'] == "NestWarmUpIntent":
            setTemp = nest.setTurnUpTemperatureAll(userId)
            if setTemp is not False:
                output_speech = "Turning up the Nest to an average temperature of " + str(
                    setTemp) + " degrees."
                output_type = "PlainText"

                card_type = "Simple"
                card_title = "Nest Control - Setting Nest Temp"
                card_content = "Telling Nest to set to " + str(
                    setTemp) + " degrees fahrenheit."

                response = {
                    "outputSpeech": {
                        "type": output_type,
                        "text": output_speech
                    },
                    "card": {
                        "type": card_type,
                        "title": card_title,
                        "content": card_content
                    },
                    'shouldEndSession': True
                }
                return response

            else:
                return nest.generateError('Unknown Error', 'Warm Up')

        elif request['intent']['name'] == "NestSetAway":
            setTemp = nest.setModeAll(userId, 'away')
            output_speech = "Setting Nest to away"
            output_type = "PlainText"

            card_type = "Simple"
            card_title = "Nest Control - Setting Nest To Away"
            card_content = "Setting Nest to away mode."

            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'] == "NestSetHome":
            setTemp = nest.setModeAll(userId, 'home')
            output_speech = "Setting Nest to home"
            output_type = "PlainText"

            card_type = "Simple"
            card_title = "Nest Control - Setting Nest To Home"
            card_content = "Setting Nest to away mode."

            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, userId,
                request)  ##Just do the same thing as launch request
Exemplo n.º 4
0
def intent_request(session, userId, request):
	print "intent_request"
	print request

	if not nest.isValidNestUser(userId):
		alexaId = genNewAlexaId(userId,10)
		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 - Setup"
		card_content = "Current user is not a valid nest user. Please authenticate user with userId: " + alexaId + " to Nest as instructed on the website"

		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}

			print nestTempValue
			if int(nestTempValue) <= 90:
				nest.setTemperatureTargetAll(userId,int(nestTempValue))

				return response
			else:
				return nest.generateError('Temperature out of range','Set Temp')


		elif request['intent']['name'] ==  "NestCoolDownIntent":
			setTemp = nest.setTurnDownTemperatureAll(userId)
			if setTemp is not False:
				output_speech = "Turning down the Nest to an average temperature of " + str(setTemp) + " degrees."
				output_type = "PlainText"

				card_type = "Simple"
				card_title = "Nest Control - Setting Nest Temp"
				card_content = "Telling Nest to set to " + str(setTemp)  + " degrees fahrenheit."

				response = {"outputSpeech": {"type":output_type,"text":output_speech},"card":{"type":card_type,"title":card_title,"content":card_content},'shouldEndSession':True}

				return response
			else:
				return nest.generateError('Unknown Error','Cool Down')



		elif request['intent']['name'] ==  "NestWarmUpIntent":
			setTemp = nest.setTurnUpTemperatureAll(userId)
			if setTemp is not False:
				output_speech = "Turning up the Nest to an average temperature of " + str(setTemp) + " degrees."
				output_type = "PlainText"

				card_type = "Simple"
				card_title = "Nest Control - Setting Nest Temp"
				card_content = "Telling Nest to set to " + str(setTemp) + " degrees fahrenheit."

				response = {"outputSpeech": {"type":output_type,"text":output_speech},"card":{"type":card_type,"title":card_title,"content":card_content},'shouldEndSession':True}
				return response

			else:
				return nest.generateError('Unknown Error','Warm Up')


		elif request['intent']['name'] ==  "NestSetAway":
			setTemp = nest.setModeAll(userId,'away')
			output_speech = "Setting Nest to away"
			output_type = "PlainText"

			card_type = "Simple"
			card_title = "Nest Control - Setting Nest To Away"
			card_content = "Setting Nest to away mode."

			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'] ==  "NestSetHome":
			setTemp = nest.setModeAll(userId,'home')
			output_speech = "Setting Nest to home"
			output_type = "PlainText"

			card_type = "Simple"
			card_title = "Nest Control - Setting Nest To Home"
			card_content = "Setting Nest to away mode."

			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, userId, request) ##Just do the same thing as launch request