Integrating Nest with Amazon Echo (Alexa)

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!

Tags: , , ,

911, Telephones and Technology

Recently I haven’t had the chance to write many articles, but today I wanted to share with you an article I can cross-post here and also over on http://blog.squarebaboon.com/. The Square Baboon Blog is a blog I share with my college roommate and best friend Joe Sus, where we share photos of various telephones we come across in our day-to-day lives. Note – Joe does a much better job at posting phones than I do. None the less, I digress…

Today’s post is about 911 and calling as well as some of the terminology associated with it. First off, let’s take the place you’re actually calling when you call 911. That’s called a PSAP:

PSAP is short for Public Safety Answering Point. Essentially, it’s the dispatch center you’re routed to when you call 911.

Here’s the cool thing about PSAP’s – they’re regulated by the FCC. What does that mean? Well, if you’re interested in the closed PSAP to you or maybe a PSAP in your general area, you can head over to the FCC’s website and find that information (https://www.fcc.gov/encyclopedia/9-1-1-master-psap-registry).

Now, let’s take it a step further. When you call 911, the PSAP will use ANI and ALI.

ANI is Automatic Number Identification. In basic terms, this is Caller ID. It displays information about the line calling 911 to the PSAP.

 

ALI is Automatic Location Identification. The idea behind ALI is that if you’re calling from a land line, the PSAP can get where you live without you even telling them! In terms of a cell caller calling a PSAP, ALI will try it’s best to triangulate your location.

Got all of that? Now let’s throw the wrinkle in to it – the Internet. More and more people are subscribing to Voice Over IP (VoIP) services and when you call 911 from a VoIP line, the PSAP you get as well as your ALI could be completely wrong. Even if you take VoIP out of the picture, ANI and ALI can be “misconstrued” if you work for a company that centralizes all of its telephony and does LCR to try to get the best cost for each call made.

LCR is Least Cost Routing. Essentially it’s sending a telephone call out of the telephone network as close as it can to the number the call is being made to. For example if your company has an office in the Netherlands, but you sit in Chicago and you want to make a call to Amsterdam, LCR would route your call “out” of the Amsterdam office, keeping the call costs as low as possible.

So, we’ve barely scratched the surface, but you can see what all goes in to telephony as well as 911 calls. I hope I’ve given you some food for thought as well as a few new cool terms to use. So, next time you think about buying a VoIP telephone line in order to get LCR, make sure if you call 911, you might be misleading the PSAP with invalid ANI and ALI 😉

-Justin

Tags: , , , , ,

Installing MRTG and RRD in Azure on Windows Server 2012R2

It’s been a while since I wrote anything down, albeit I’ve been keeping very busy. This week though, I’ve been digging through lots of articles and such and it triggered a thought in my mind…If I document what I do publically, I can always go back and look at it (I refer to my booting an OS from a USB article all too often) and also I can share my experiences with the broader world!

Today’s post as the title alludes to takes us down the MRTG route in the Azure world. First off, MRTG is a great program that was written many years back by a guy named Tobi Oetiker. The latest release is 2.17.4 which was released in January 2012, yet it’s still a great tool. The simple idea behind it – you run a script every 5 minutes that takes two input variables and then it graphs them. The most common use for this is routers – in and out packets – hence the name MRTG (Multi-Router Traffic Grapher). However, you can do just about anything you want with MRTG. One of the things I do with it is simply plot the same number twice in some instances which gives a great effect to the number I’m displaying (say the number of active helpdesk calls).

At any rate, with the ability to go Hybrid Cloud, the premise of this article is to explain how to get it working in Azure on Windows 2012R2 (sure you can do the same on-prem too)…If you’ve got an MSDN account, you’ve got monthly credit to use too, that’s what I do with mine :)  So, let’s get going:

1. Create a new VM in azure (New -> Compute -> Virtual Machine -> Quick Create)

Windows Server 2012R2 Datacenter – Basic A0 is what I went for

create-vm

2. After the VM Builds, log in and patch it

3. Turn off IE Enhanced Security (for the time being) – Server Manger -> Local Server -> IE Enhanced Security

4. Download the latest version of ActivePerl

5. Run the ActiveState installer and install to c:\perl64 (the default directory)

6. Download the latest MRTG Windows .zip file

7. Unzip the package to c:\

8. Rename mrtg-2.17.4 it to mrtg

c mrtg

9. Download the latest WebPI

10. Run the Web Platform Installer and choose to install PHP 5.6.0 (Note this will install 19 “components”)

11. Download the x86 version of the Visual C++ Redistributable 2012 (even if you have an x64 install use the x86 version of the C++ package because PHP will run x86) Install PHP 5.6.0 (optional)

12. Install the Visual C++ Redist

13. Download the PECL library for RRD (ensure it’s 5.6 Non Thread Safe (NTS) x86)

14. Copy the following .dll files in to to c:\program files(x86)\php\v5.6\ cairo, expat, fontconfig, gobject-2, pango-1, pangocairo-1, pangoft2-1, pangowin32-1, pixman-1, rrdlib

standard dlls

15. Copy php_rrd.dll in to c:\program files(x86)\php\v5.6\ext\

16. Open c:\program files(x86)\php\v5.6\php.ini and add the following to the very bottom of the file “extension=php_rrd.dll”

php rrd dll

17. Open notepad and create a file that has “<?php phpinfo();?>” in it (sans the “‘s)

phpinfo

18. Save this file to c:\inetpub\wwwroot as “about.php” (make sure you put “‘s around the file name so notepad saves the .php extension)

 save as

19. Open IE and navigate to http://localhost/about.php to see it’s installed correctly

php about screen

20. Scroll further down to also see that the RRD library is enabled

rrd lib enabled

21. Open a command prompt

22. Change the directory to c:\mrtg\bin

23. run “perl mrtg”

perl mrtg

If MRTG is installed correctly, you’ll see the program disclaimer.

Voila!

The next article will talk about what you can do with MRTG and PHP together. Hope you enjoyed!

Tags: , , , ,

Creating Mobile Websites

First off, apologies as it’s been quite a while since I’ve made a posting. I’m gonna try and change that :) I’ve really got no excuse. So, to try and get back in the groove, I’ve just created a new website project that uses varying parts of PHP to do a number of things – mostly to keep me informed of the ever changing Washington State weather. It has a configuration file that has a listing of all of the passes in Washington State and then from the pass names, it has a few arrays that specify cameras, etc and them embeds them in to a mobile based website:

http://wsdot.227volts.com/

Check it out. It defaults to Snoqualmie Pass because that’s the one I travel over most. However, you’ll notice at the top left, the three horizontal bars. If you click on the three bars, by default it will show you the cameras associated with that pass. The cool feature however is if you click on the pass name at the very top of that menu system, it will take you to the “main menu” and list all of the passes. Simply click on your pass of choice and presto, you now are whisked away to that pass and all of the associated cameras. It also uses the WSDOT RSS feed to grab the weather quickly so you’re always up to date. No need for an app, no need to have to pinch and zoom on WSDOT’s site, you’re all set!

If you like it or have feedback or comments, please let me know!! Send me an email – my address is simply justin@227volts.com!

Enjoy!

Using algorithms to evaluate status

Today I had an interesting one happen. Starbucks has a reward program wherein if you use their card 15 times you go to a “Gold Level”. Once at that gold level, it keeps rotating every 15 times. You can check the status by simply logging in to their website and go to your “My Rewards” page or your account. Interestingly enough, today when I logged in, I got a page that said “Gold Level” however to spread the word about the program, they provide you with a social media plugin (FB & Twitter) at the bottom. Somehow though, because I was at the reset point (0/15) the reward plugin wanted me to tweet I was at a Welcome level:

image

Hmm, looks like there might be some work needed on that algorithm Starbucks Winking smile

Tags:

Send me email at my web address–what?

So, I take the bus to and from work every day as I’m still a bit European in my ways. The bus company – I won’t mention any names – recently announced some new routes and as such they’ve posted announcements about the upcoming changes. Have a look at this one, which I found funny (at 6 a.m.!):

proposed route 234

The best part, which like I said, made me laugh at 6:00 a.m. was Jack’s email address in the last paragraph. If you’ve got problems you’re supposed to send him email at jack.whisner@kingcounty.gov/metro which makes me wonder Jack, do you want me to email you or go to the website cause that surely isn’t an SMTP compliant address.

DOH!

Tags: , , ,

Dear Columbia, you need a java update

So, the winter season is upon us and so are the updates. Yep, I’ve found another one. Was shopping for a new winter jacket the other day in the Columbia store, and what did I come across? You guessed it, another kiosk infraction (and it’s running XP – yuck)!

DSCN2129

Let’s take a closer look at that there kiosk:

DSCN2126

Hmm, how about a bit closer?

DSCN2128

Yep, Java Update Available. Yet another reason why automatic updates are a bad idea (especially on kiosks).

Tags: , , , ,

Is United Ready for Continental?

Over the past ten years travel has been a necessity in the business I’m in. I’ve had to travel all around the world for various clients, projects, meetings, etc. As such, I’ve been a Delta Platinum/Diamond member for multiple years, Virgin Atlantic Silver/Gold member, Scandinavian EuroBonus Gold member and most recently United Premier Executive (I’m only a few miles away from 1K status).

In the recent months of travelling on United, Jeff Smisek, CEO of United prefaces each safety video with the fact that as of October 1, 2010, Continental is now United and United is Continental. This is also the focus of many of the articles in Hemisphere and it got me thinking, is United really ready for Continental or are they going about this without planning? Here’s my thoughts:

Painting Planes

In both the October 2010 Hemisphere’s as well as now in the November article, it’s pointed out that the first thing we’ll see as frequent flyers is the new livery. Big Deal. Here’s a suggestion, why don’t you take the money it takes to paint the plane and invest it in something worthwhile, rather than making sure the new United font is on the outside and the globe is on the tail. What do I mean? Well, a while back United was a pioneer in on-board wireless connectivity. They boast about being the business man’s airline, yet when I get on board, I don’t have wireless capabilities. Almost every other airline does. Take the money you’re using to paint the planes and put it to something more useful.

Take care of your Frequent Flyers

Currently in the Miles Plus Frequent Flyer scheme, there are five tiers (four if you count the default one) – Premier, Premier Executive, 1K and Global Services. The last tier is a coveted one for buying loads of full fare tickets but the others are attainable by flying more often. However, while there are some “perks” with each tier, in my years of travelling, the perks with United are minimalistic when it comes to flying and it seems as if they don’t care too much. Here’s an example. I was on an international flight the other day and asked if business had checked in full. The gate agent said no. I asked as a Premier Executive if there was anything I could do to get an upgrade and their response – no. Again, this is something small, but other airlines give vouchers as that level and also should Business Class not check in full, be kind to those that travel often and give them a complimentary upgrade – after all, the food is already on the plane and the person is going to be on the plane as well.

Continuity

October was a busy month and I got to go both east and west – essentially crossing both oceans. What I noticed amazed me. There is no continuity between overseas flights on United. What do I mean? Well on a flight from Seattle to Tokyo – an international flight – alcohol is free. Yet, take a flight from Chicago to Amsterdam (same distance), again another international flight, but this time you’ll get charged $6.00 for alcohol. Another small thing, but the mapping program onboard…go east you get one version, go west you get another one. Further, go west and it will end up in English as well as the destination language. Go east and it will only be in English (however I must say the east bound version seems newer, more clean and the better of the two versions).

Channel 9

United was really on to something good when they introduced Channel 9 on to their planes. I remember about 4 years ago finding this channel and thinking, wow, for the avid flyer, this is pretty cool. For those of you unfamiliar with Channel 9 it’s “straight from the cockpit” wherein you hear the communications of the pilot with ATC. However, the problem with channel 9 is it’s like a crap shoot. One plane will offer it, one won’t and there isn’t any reason why. Sometimes pilot’s tell you they’re going to do it, other’s just ignore it and there’s no method to the madness. Why not write in to the policy of the flight attendant or even the pilot in his/her intro message to tell you about channel 9, as you were really on a winner on this one, but now it’s hit or miss…

Conclusion

There are more than the above I’ve noticed however they are some of the main ones. Another one that makes me laugh is that United don’t seem to provide luggage tags for Frequent Flyers (it promotes your airline after all guys), yet every other airline does. It gets so bad that a group of people over at FlyerTalk have devised their own. Again, is it important to update the livery rather than simply print luggage tags for those who fly often with you?

In short, I think United really has some housekeeping they need to look at/address first before they think that taking on Continental is the best thing to do. After all, what are you going to do when merging Continental traveller’s in to your system? The elite get free standby and we don’t on United and their top tier is 75,000 miles not 1K.

Seems United is trying to run before it can walk…Just like any IT project – planning is critical here and I’ll be interested to see what comes off the back of this grandiose plan/scheme that Mr Smisek says “good things are going to come from”…

Adding the cool factor to Microsoft

With the upcoming release of Kinect for the Xbox (everyone should have gotten a system update within the past few days), Microsoft has added one other “cool” factor to the marketing push for Kinect. The executive team at Microsoft, who are prominently displayed on the Press Pass site:

http://www.microsoft.com/presspass/exec/a-d.aspx

have all been turned in to avatars, with the exception of Sinofsky.

execs

I don’t see Apple doing this any time soon, nor does Nintendo have Wii characters for their executive board Smile

Tags: , , ,

Dear SeaTac, I upgraded your kiosk for you

So the other day I flew in to SeaTac thinking, wow, I haven’t seen any blue screens or problems recently (ok, I did see a few but didn’t have my camera), when BANG. At that moment, walking to catch the bus (yes I take the bus to and from the airport), I came across a kiosk and it had a dialogue box up. Most of the time when I come across a kiosk with a dialogue box it is usually stating it needs a reboot, however this one, strangely enough wanted to upgrade…something I don’t think should/is/was supposed to be a consumer task. At any rate, here is the kiosk:

DSCF1361

and the close up of the kiosk:

DSCF1360

so, I went ahead and clicked update for the version update for SeaTac. Not sure if you’re now out of EULA or your license allows you upgrades to LogMeIn or not, but hey, you gave me the chance/option to upgrade and as we all know, the newer the better and with software always use the latest and greatest, right?! Smile

Tags: , ,