How to Control X10 Devices With Amazon Echo or Google Home
by stuffman in Circuits > Gadgets
53553 Views, 51 Favorites, 0 Comments
How to Control X10 Devices With Amazon Echo or Google Home
In this instructable I’ll show you how to use your Amazon Echo or Google Home device to control X10 hardware. Why X10? Well, a lot of us jumped on the home-automation bandwagon early (since X10 is over 40 years old it’s possible that you’ve been using this hardware for a really, really long time), and don’t care to go out and spend a bundle on Philips Hue or WeMo lights to replace what already works for us. Also, the vast number of options with X10 allows, in my opinion, for a more flexible implementation of lighting control for the casual enthusiast, or the person who wants to install X10 compatible outlets, lamp or fan modules. In the end, X10 does what the newer lamp control modules do: It turns your lights on and off.
First, You Need a Computer.
In order to make this work, you’ll need a computer with a serial port. I’m using a small form factor PC that happens to have a serial port, so I’m using the CM17A firecracker module that can be found on eBay for less than $10.00. For the receivers, I use the TM751 modules, which listen for radio signals (such as those from the firecracker module) and inject those signals onto the electrical circuits running through the house. I also have various X10 in-wall switches, inline appliance modules and lamp modules throughout my house.
This how-to varies slightly whether you’re running Microsoft Windows or some flavor of Linux. I happen to run Linux, but have had this running on a previous iteration of my home server, which ran Windows 7. I will proceed with this tutorial showing how this is done with Linux, because in my opinion things tend to work more reliably under that OS.
Bottlerockets and Firecrackers
The CM17A ‘Firecracker’ module can be operated via command line with a linux application called Bottlerocket. Commands are passed to the module and are turned into wireless signals which are then picked up by the transceiver modules. Here’s what a command looks like:
br --port /dev/ttyS0 --house=B --on 4
br: This is the executable Bottlerocket application --port /dev/ttyS0: This tells Bottlerocket which serial port to use --house=B: This tells Bottlerocket which house code you’re on --on 4: This tells Bottlerocket to send the ‘on’ command for unit code 4
Let’s say that the previous command turns your living room light on. Save the command as a file called “LivingRoomLightON”. Then in a terminal session, run this command: Chmod +x LivingRoomLightON This command makes the script file you just created executable. Check to make sure it works by (while still in a terminal session) running: ./LivingRoomLightON
Your living room light should turn on, assuming that /dev/ttyS0 is the serial port that the firecracker is installed on. (And that it’s plugged into the serial port). At this point you can create and test scripts for each device in your home.
So, if you are successful at this point, give yourself a hand. You’re not too far from being able to use your Amazon Echo to control your lighting.
**The purpose of this instructable is to show how to use the Amazon Echo with X10, but even at this point you have a pretty powerful setup using just a Linux server and the Bottlerocket software. With little more than what you’ve already done, you can set up cron jobs to automatically turn lights on and off. Cron even allows you to set a job per month so that you can set the lights to come on around sunset and sunrise, with a new job for each new month. Pretty cool!
Where's That Confounded Bridge?
Now we need to download the truly magical piece to this whole setup. BWS Systems (http://bwssystems.com) has released an excellent conduit software that sits between your humble home automation server and your Amazon Echo. It’s called the HA Bridge, and can be downloaded from http://bwssystems.com/#/habridge.
Download HA Bridge
Use wget to obtain the lateset version of the HA Bridge. First, go to http://bwssystems.com/#/habridge, then copy the download link (in chrome, right click the download link, then click copy link address). In a terminal session, type “wget downloadlink”. At the time of this writing, the command would look like this:
wget https://github.com/bwssytems/ha-bridge/releases/d...
This command downloads the HA Bridge java file to the local directory. Once you have the .jar file downloaded, run the command “java -jar nameofjarfile.jar” At the time of this writing, that command looks like this:
java -jar ha-bridge-3.2.2.jar
Open a browser window either on the Linux server or on another network PC, and go to http://ipofserver:8080. You should see the HA Bridge configuration screen. This screenshot is my configuration, yours will be empty at first.
Click on “Manual Add”. This will take you to the new device entry screen. First, name the device. You can see from the screenshot of my completed configuration what I’ve named my lights, but you’ll want to choose something that makes sense for your application.
Under Device Type, drop down the list and choose “Execute Script/Program”.
“On URL” is the script that will run to turn this light on. An example of one of my working scripts is /home/myself/LivingRoomLightsOn
“Off URL” is the script that will run to turn this light off. An example of one of my working scripts is /home/myself/LivingRoomLightsOff
Click “Add Bridge Device” to add this to the list of devices. You should now see this when you click “Bridge Devices”. Click “Bridge Devices” and click “Test On” or “Test Off”. If all is configured correctly, the HA Bridge should be executing the scripts for On and Off when you click the corresponding button.
Now for the Alexa Part!
Once everything is tested, you should be able to have your Echo scan for new devices. You can do that by saying, “Alexa, scan for devices”, or go to http://alexa.amazon.com and use the webUI to scan.
A word on Google Home - I don’t have a Google Home device, but the BWS Systems’ website says that the HA Bridge is confirmed to work with Google Home. If anyone would like to send me one to test, I’d be happy to report back :)
At this point you should be able to ask Alexa to turn your lights on and off! One more thing, though. You will need to launch the .jar file each time you boot the server. Here’s the easiest way to do that. Open a text editor and paste the following into a new document:
cd /home/myself/Lighting /usr/bin/nohup /usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -jar ha-bridge-3.2.2.jar
Save this new document as “starthabridge.sh”. Make this new script executable by issuing this command in a terminal session: chmod +x starthabridge.sh
Now that we have a script, we need to tell the system to launch it at each boot. Issue this command (again in a terminal session):
sudo crontab -e
This is the Cron editor. From here you can schedule tasks to run automatically, or, in this case, tell the system to run a command at boot. Here’s what you should add to the end of your cron to get the Home Automation Bridge to launch at startup:
@reboot /home/myself/Lighting/starthabridge.sh
Drumroll Please....
...And that should be it! You can get this same thing going with Microsoft Windows using the same .jar file from bwssystems and a command line utility for Windows called cm17a.exe. The syntax is different (check the github page for usage), and in my experience, it is slower to issue the commands. For instance, if I ask Alexa to turn on the Living Room lights under Windows, there's a good 2-second delay between Alexa saying, "Okay" and the lights coming on. Under Linux, the lights come on before she even has a chance to say "Okay".
I hope you enjoyed this instructable, if you have any issues getting it to work, please comment and I'll try to answer.
Have fun!