I got an echo the other day and I’m excited about the functionality – especially seeing as it connected directly to my wink hub, however it didn’t connect to my nest thermostat, so I got a bit discouraged…However after a bit of trial and error as well as a few scripts on the internet, I’m happy to say, my Nest is now connected to the Echo. I can set the temperature, turn it up, turn it down (in three degree increments) or just check the temperature it is. How did I do it? Pretty simple…Here’s the prerequisites

Now that we’ve got all of that sorted, let’s dig in.

Go ahead and create the Azure Web App and in the root directory, copy nest.class.php from GitHub there. After you’ve created that file, go ahead and create an index.php (maybe you want to bury the two files a directory deeper than the root for “additional” security)…

Once you’ve created index.php add the following code to it (note you’ll need your username and password):

<?php
require_once(‘nest.class.php’);
define(‘USERNAME’, ‘mynestuser@gmail.com’);
define(‘PASSWORD’, ‘my-nest-password’);
$nest = new Nest();
$nest_detail = $nest->getDeviceInfo();
$EchoJArray = json_decode(file_get_contents(‘php://input’));
$intent = $EchoJArray->request->intent->name;
$ct = $nest_detail->current_state->temperature;
if ($intent == “NestSetTempIntent”) {
$new_temp = $EchoJArray->request->intent->slots->temp->value;
$nest->setTargetTemperature($new_temp);
$feedback = “I went ahead and set the temperature to $new_temp”;
} else if ($intent == “NestCoolDownIntent”) {
$new_temp = $nest_detail->current_state->temperature – 3;
$nest->setTargetTemperature($new_temp);
$feedback = “I went ahead and set the temperature to $new_temp”;
} else if ($intent == “NestWarmUpIntent”) {
$new_temp = $nest_detail->current_state->temperature + 3;
$nest->setTargetTemperature($new_temp);
$feedback = “I went ahead and set the temperature to $new_temp”;
}
else {
$feedback = “Currently the temperature is ” . $nest_detail->current_state->temperature . ” degrees.”;
}
header(‘Content-Type: application/json;charset=UTF-8’);
$text = ‘{
“version” : “1.0”,
“response” : {
“outputSpeech” : {
“type” : “PlainText”,
“text” : “‘. $feedback .'”
},
“card”: {
“type”: “Simple”,
“title”: “Nest Integration”,
“content”: “‘ . $feedback . ‘”
},
“shouldEndSession” : true
}
}’;
header(‘Content-Length: ‘ . strlen($text));
echo $text;
?>

After you have those two files in place, you’re ready to head over to the developer portal and create a new “Skill” for Alexa and the Echo. To do this:

  • log in
  • Click on Alexa
  • Click on “Get Started” below the Alexa Skills Kit
  • Click “Add A New Skill”
  • For the Name simply enter “Nest Controller”
  • For the Invocation Name I used “nest”
  • For version I used “1.0”
  • Endpoint is the URL to the Azure website I had created (https://webappname.azurewebsites.net/nest/)
  • Click Next
  • For the Intent Schema, enter:

{
“intents”: [
{
“intent”: “NestCoolDownIntent”,
“slots”: []
},
{
“intent”: “NestWarmUpIntent”,
“slots”: []
},
{
“intent”: “NestInquireIntent”,
“slots”: []
},
{
“intent”: “NestSetTempIntent”,
“slots”: [
{
“name”: “temp”,
“type”: “NUMBER”
}
]
}
]
}

  • For sample utterances enter:

NestSetTempIntent set temperature to {seventy four|temp}
NestSetTempIntent set temperature to {eighty one|temp} degrees
NestSetTempIntent set to {sixty one|temp}
NestSetTempIntent set to {eighty one|temp} degrees
NestSetTempIntent set {sixty one|temp}
NestSetTempIntent set {eighty one|temp} degrees
NestSetTempIntent set thermostat to {sixty one|temp}
NestSetTempIntent set thermostat to {eighty one|temp} degrees

NestCoolDownIntent turn the temperature down
NestCoolDownIntent temperature down
NestCoolDownIntent I’m too warm
NestCoolDownIntent I’m burning up
NestCoolDownIntent burning up
NestCoolDownIntent i’m too hot
NestCoolDownIntent too hot
NestCoolDownIntent cool down
NestCoolDownIntent cool the house down
NestCoolDownIntent turn the thermostat down
NestCoolDownIntent thermostat down

NestWarmUpIntent turn the temperature up
NestWarmUpIntent temperature up
NestWarmUpIntent I’m cold
NestWarmUpIntent I am cold
NestWarmUpIntent I’m too cold
NestWarmUpIntent it’s cold
NestWarmUpIntent its cold
NestWarmUpIntent it is too cool
NestWarmUpIntent it is too cold
NestWarmUpIntent it is freezing
NestWarmUpIntent it’s freezing
NestWarmUpIntent it is chilly
NestWarmUpIntent its chilly
NestWarmUpIntent warm up the house

NestInquireIntent current temperature
NestInquireIntent what’s the temperature
NestInquireIntent what’s the current temperature
NestInquireIntent what’s the temperature inside
NestInquireIntent what’s the temperature indoors
NestInquireIntent what is the temperature
NestInquireIntent what is the current temperature
NestInquireIntent what is the temperature inside
NestInquireIntent what is the temperature indoors
NestInquireIntent why am I freezing
NestInquireIntent why am I burning up

  • Click Save
  • Click Next
  • For SSL Certificate choose the middle “My development endpoint is a subdomain …” (All *.azurewebsites.net addresses have an https wildcard certificate associated with them)
  • That’s it!

Now it should show up in your skills list on your Echo App (iPhone, Android or even on https://echo.amazon.com/). To invoke any of the commands simply ask or tell Alexa what we listed above…For example:

  • Alexa tell nest turn the temperature down
  • Alexa ask nest what is the temperature inside
  • Alexa tell nest set temperature to 68 degrees
  • Alexa tell nest its chilly

Feel free to add more utterances based on the slot of what you’d like her to do. If you want to turn the temperature down, simply prefix your “alexa tell/ask nest” command with NestCoolDownIntent in the utterances. To turn it up, simply use NestWarmUpIntent .

Have fun!