Playing with Home Automation

Over the course of the last year, I've been slowly accumulating home automation toys. Our living room and guest room have Logitech Harmony universal remotes, which I highly recommend. In the living room, we have the Harmony Ultimate One, which not only controls the home entertainment devices, but can integrate with a number of other devices, including our Philips Hue lights. In December, we added an Amazon Echo to the mix.

Right now, we have one Echo, but we've another on order because, well... because we want one.

GETTING TO KNOW AMAZON ECHO (Alexa)

It didn't start out that way. It takes time to build a working relationship with the device. When it first shows up, the relationship is based almost entirely on novelty. We asked it all sorts of silly questions and hunted for easter eggs such as, "Alexa, who lives in a pineapple under the sea?", "Alexa, your mother was a hamster.", and "Alexa, what is the airspeed velocity of an unladen swallow?" After a couple days of referring to the device as "Alexa", I found myself referring to it by gender. I'm still not sure how I feel about that. I don't gender reference my automobiles, computers, or home entertainment system, but given the voice is distinctly feminine, I went with it.

Unfortunately, it doesn't take long before the novelty fades and you find yourself wondering if this thing is actually useful. The first thing we found we were using regularly was its ability to play music. Say, "Alexa, play smooth jazz from Amazon Prime.", and, assuming you have an Amazon Prime account, she'll play the top smooth jazz from Prime. No prime? No worries. She works with Spotify, Pandora, and several others. Ask her for the weather, news, or traffic and she's at the ready. And, of course, she can order things off of Amazon for you with a single command. This is a feature not to be used lightly.

Alexa can control the house (sort of)

For me, the breakthrough was when I discovered the home automation features. Under "Settings" on the Alexa site is a "Connected Home" option. From there, you can tell Alexa to discover devices in the home. Sure enough, she could see the lights. A bit of configuration, and I could say, "Alexa, turn on the office lights" and a few other commands. I haven't touched the light switch in the office since (she resides in the office).

Being the geek I am, it didn't take long before I wanted to do more than just turn the lights on or off. I wanted to be able to activate my Hue scenes, adjust the brightness, and even mess with the hue and saturation. I wanted to be able to say things like, "Alexa, let's start the day.", and have her turn on specific lights, read me my agenda for the day, turn on the tv to my favorite morning news show, and start the coffee pot.

No such luck. While the command set is improving, we're a long way from where I'd like it to be. I was back to, "Alexa is a nice little music player with benefits."

Pairing with Corey Haines on stage at SCNA 2010

Pairing with Corey Haines on stage at SCNA 2010

But wait....

I can haz Ruby!

Ah, the benefits of being able to code. Even if I am a tad rusty.

Some searching about and I found a Github repo by Steven Arkonovich who seems to have a good amount of experience writing handy little apps for Alexa.

The README contains all the information you need to get this set up and running. As a warning, there are a number of steps, including creating a lambda function for handling Alexa skills and creating a skill with the Alexa skills kit along with setting up ngrok to create a tunnel to your internal server which needs to be on the same network as your Hue Lights.

I already had an Amazon developer account, which isn't too difficult to get set up, and I was able to get the rest of this running in a little over an hour. The majority of that time was updating my local ruby environment as I was a few versions behind on everything. So, you know, the usual Yaks to shave...

Digging the functionality, but feeling like the code maybe wasn't my particular style, I forked the repo and have been working on creating some tests and refactoring the code to a point where I can feel comfortable extending it.

As of today, it only controls my Hue Lights, but it is a serious improvement. I can give it all sorts of commands that are not available on Alexa. And in short order, I'll be able to do a whole lot more.

Once I get this piece completed, I am going to add in the ability to control the Logitech Harmony hub. There is an API, but it is not published to the public. Logitech had an open developer program, but they claim the demand was too high, so they restricted it to approved partners. That's a hurdle, but not impossible to overcome. IFTTT already integrates with Harmony and through their new Maker Channel, you can control anything IFTTT provides. Then, there's all the folks who've reverse engineered the API and made examples available. One way or another, I'm gonna make this happen.

I'm not going to rest until I can say, "Alexa, use Home Control and start the day." and sit down in front of the tv to watch the news in my perfectly lit living room with a cup of coffee - all without having touched a single switch or button.