/ alexa

Building Voice Controlled Home with Amazon Echo and Dot

I always wanted to have personal assistant that can answer stuff and control my house like Tony Stark in Iron Man.

Amazon and Google are already working on it. So far we have Amazon Echo and Google Home.

I thought: hmm…. my home has already home automation system in place so why not try to control it with voice !

Unfortunately none of these devices is available in the country here I currently live (Spain). But surprise surprise Amazon let’s you make your own Amazon Echo using just Raspberry Pi (only version 2 and 3)!

You will need:
– Raspberry Pi2
– Speaker with 3.5mm line in (So you can hear Alexa responding)
– USB microphone or Webcam with microphone

I followed these instructions to build one. Very straight forward:

https://github.com/alexa/alexa-avs-sample-app/wiki/Raspberry-Pi

Amazon Alex on Raspberry Pi

So now how do I hook it up with any home automation system? Well, any system which can accept commands via TCP/IP can be controlled easily and there are two ways to accomplish it: easy and let’s say more challenging.

Amazon Echo with IFTTT – the easy way.

Amazon Echo with IFTTT

First of all we will need web server accessible to outside world. In my case I use IIS and web service developed using .NET. My server is accessible through dynamic dns. Remember to open necessary ports.

Basically, web service translates web requests to TCP commands understood by the device you wish to control.

Then you need to talk to your Home Automation system via TCP/IP:

Here is a link to an example on github:
https://github.com/KlaatuVerataNecto/amazon-alexa-ifttt-home-automation-dot-net

Once it is up test your web service:

Important: this is just for demo purposes and you shouldn’t leave it on as anyone can control your lights by knowing this url. I’m working on introducing a token and using SSL which will secure it a bit more.

Alternatively you can use Python to setup web server and relay commands to our home automation system or directly control GPIO pins.

Run it by launching:

python web_server.py

*Latest Raspbian comes with Python and Flask already installed

Once it is up test your web service:

Now we need to create an account with https://ifttt.com/ and create these Recipes or as they call it now Applets:

When you add Alexa for the first time it will ask you to login to your Amazon account. This way Alexa will be able to see your IFTTT Applets.

IF Alexa

Alexa integration with IFTTT

THEN Maker

Alexa integration with IFTTT

Now just say

Alexa trigger kitchen lights

and here is a result:

Now. lets talk about drawbacks:

  1. My system is wide open to the world, anyone knowing this url can trigger my lights

  2. There is a delay when issuing command:

Alexa

(~ 2 seconds)
“beep”

trigger office lights

(~ 2 seconds)
“beep”

sending that to ifttt

(~ 2-5 seconds)
lights turn on

  1. I’m unable to change “Alexa”. How about calling it Jarvis?