This is an old revision of the document!
Table of Contents
CONTROL OPENHAB ITEMS USING THE AMAZON ECHO
INTRODUCTION
Having a digital personal assistant, like Jarvis from Iron Man, is the ultimate geek dream. Over the past few years, most of the major tech companies have attempted to turn this dream into reality. Apple has Siri, Microsoft has Cortana, and Google has Google Now. Even some smaller companies have tried their hand: SoundHound recently launched their Hound app which focuses on natural language processing and a speedy response to your queries. All of these companies have something in common, though. They’re all focused on using your mobile phone as the input device.
Amazon has taken a different approach with their Echo “smart speaker”. The Echo is a stylish, cylindrical speaker which is meant to be displayed on a coffee table, kitchen counter, or your nightstand. However, the important part of Echo is what it’s doing: listening. Simply speak the trigger word at any time (“Alexa” by default) to make the Echo spring to life and await your command. That’s why it’s the perfect home automation controller. It’s hands-free!
In this post, I’m going to show you how to control your OpenHAB items using the Amazon Echo. Let’s begin!
PREREQUISITES
First thing’s first. Get your Echo all set up and decide where you’d like it to sit. I played around with mine for about 15 minutes before I decided to get down to business and set it up with OpenHAB.
You’ll need to download a great little piece of software from GitHub named Amazon Echo HA Bridge. The author, Armzilla, uses this to control a Vera from his/her Echo, but we’re going to use it to control OpenHAB. Download the latest release to your OpenHAB PC. I’m using version 0.1.2. You’ll also need Java 8 installed in order to run the software.
Finally, we’ll need a Chrome extension named Postman. We’ll use this to upload our settings into the Echo HA Bridge. You may use another REST client if you wish, but I won’t cover that in this guide.
STEP 1: RUN THE AMAZON ECHO HA BRIDGE
Okay, enough beating around the bush. Let’s get into it! The first thing we need to do is run our Amazon Echo HA Bridge. Open a command prompt window and navigate to the folder where you stored the Amazon Echo HA Bridge .jar file. (Or use this shortcut! Navigate to the directory in Windows Explorer, then hold shift and right click in the white space. Choose option “Open command window here”. See below picture for an example!)
Then, you’ll want to enter this command in the command prompt window. NOTE: You may need to replace the .jar filename and the IP address with your own! You should enter the IP address of the PC you’re running it on.
java -jar amazon-echo-bridge-0.1.2.jar --upnp.config.address=192.168.1.88
Warning: If you’re running the Bridge on the same PC as your OpenHAB server, you’ll probably need to change the port that it listens on. This is because OpenHAB and the Echo HA Bridge both default to port 8080. To change the port the Echo HA Bridge is listening on, add this flag to the end of the command:
–server.port=<port>
After you run the command, there will be a bunch of output which you can ignore unless you run into issues.
STEP 2: LOAD CONFIGURATION DATA INTO THE AMAZON ECHO HA BRIDGE
This is where the Postman Chrome extension comes into handy. We need to upload our configuration data in JSON format using a RESTful API. Don’t freak out! It’s not that hard. I’ll walk you through it.
When you open Postman, you need to make sure the settings are correct. You need to make sure you’re in POST mode, have the correct address filled in (It should be http:<ip address>:8080/api/devices), and have raw data and JSON selected. Questions? Refer to the picture below! I’ve highlighted all of the critical areas.
Now we need to post the data. Refer below for an example of a setting I’m using. Lights is an OpenHAB Group that turns all of my lights either on or off. “All the lights” is the string that your Echo will react to. Make sure this is a good description for your light or item. Examples could be “deck light”, “living room light”, “hallway light”, or even something cool like “netflix” if your OpenHAB is able to control your TV!
Note that if you’re running the Echo HA Bridge on a different PC than your OpenHAB, you’ll need to replace both spots where it says “localhost” with your OpenHAB IP address. You also may need to change the ports from 8081 to something different, depending on which port your OpenHAB is listening on.
<code>
{
“name” : “all the lights”,
“deviceType” : “switch”,
“onUrl” : “http://localhost:8081/CMD?Lights=ON”,
“offUrl” : “http://localhost:8081/CMD?Lights=OFF”
}
</code>
When you are finished making your changes, click “Send” on Postman. It will scroll down and show you some output from the HA Bridge so you know it worked. You’ll need to scroll back up and repeat the process for each and every device you want to control with your Amazon Echo.