Introduction: How to Control X10 Devices With Amazon Echo or Google Home

Picture of 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.

Step 1: First, You Need a Computer.

Picture of 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.

Step 2: Bottlerockets and Firecrackers

Picture of 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!

Step 3: Where's That Confounded Bridge?

Picture of 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.

Step 4: Now for the Alexa Part!

Picture of 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

Step 5: Drumroll Please....

Picture of 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!

Comments

JamesB827 (author)2017-09-30

I was able to get this working as of September 2017 using the normal google home app on my phone and a physical Google Home appliance. It found the ha-bridge just fine and connected to my x10 devices without issue.

The new ha-bridge (v 4.5.6) has a slightly different interface than what is shown in this instructable. In the interface you add items for on, dim, and off. In each of those sections (on, dim, off) you can have multiple items / commands. In each item / command you set the TYPE to 'execute command script/program' and the TARGET ITEM to the command you want to execute (probably some bottlerocket command).

I also got dim working. The bottlerocket documentation is a little thin in this area but I eventually figured it out. So the basic command to dim or brighten is

br --port /dev/ttyUSB0 -n A4 -d 1

Obviously you replace the port with whatever port are using (I'm on an Orange Pi One using a USB to Serial adapter hence ttyUSB0). The -n is to turn on a module (so substitute A4 with whatever module you are using). Since dim / bright in X10 works on the most recently addressed module, you need to turn on the module first. The -d sets the number of steps up or down (positive numbers brighten, negative numbers dim). In my setup the max number of steps is 7 (from full on to all the way off).

The unfortunate thing about dim/bright is that the ha-bridge only gives you a new target value, it doesn't remember where you were or give you a delta. Also, the Google Home just adjusts from where you are to a lower or higher value when you say dim or brighten without an explicit target (so 'dim the lights' vs. 'dim the lights to 50%'). The X10 expects you to dim or brighten a number of steps from where you are, not go to an explicit value. Therefore, you need to know where you are currently before you can know which way to move or by how much.

To (mostly) solve this problem, I created a script that tracks the current brightness value for all my modules in a file. When you ask it to dim or brighten, it moves from where it (thinks it) was to the new value. Obviously if you externally adjust the lights without using the script, it will be confused and not work correctly. I see no way to fix this using the Firecracker as it is a one way interface (set only, not read).

Below is the script I created:

#!/bin/bash
# option processing
skip=0
while getopts ":s" opt; do
case $opt in
s)
skip=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
shift $((OPTIND-1))
# retrieve previous values
export `cat /home/habridge/x10values`
module=${1^}
value=$2
# bounds check based on how x10 actually works
# explicitly allow 0 for the 'off' notification
if [ $value -ge 225 ]; then value=255; fi
if [ $value -le 32 -a $value -ne 0 ]; then value=32; fi
if [ $skip -eq 1 ]; then opt="-s"; else opt=""; fi
# echo $(date) $0 $opt $module $value [prev = ${!module}] >> /home/habridge/x10.log
# dim or brighten based on the curr - prev value
prev=${!module}
diff=$((value-prev))
echo difference between $value - $prev = $diff
sdiff=$((diff/32))
echo scaled difference = $sdiff
if [ $skip -eq 0 ]; then br --port /dev/ttyUSB0 -n $module -d $sdiff; fi
# now save our current values
export $module=$(((value/32)*32))
echo new value = ${!module}
rm -f /home/habridge/x10values
for i in `seq 1 16`;
do
varname=A$i
echo $varname=${!varname} >> /home/habridge/x10values
done

Hopefully that helps someone else get their working.

Jason B (author)JamesB8272017-10-02

I need some help with getting this to work with google home and x10 commander app. Is there aw ay I can email you? I'm kinda lost and can't get it to work.

JamesB827 (author)JamesB8272017-09-30

I neglected to mention how I have my command configured in ha-bridge to use a combination of bottlerocket and my x10dim commands. Here's what I use:

On Items

br --port /dev/ttyUSB0 -n a4 -d 7

/home/habridge/x10dim -s A4 255

Dim Items

/home/habridge/x10dim A4 ${intensity.byte}

Off Items

br --port /dev/ttyUSB0 -r 2 a4 off

/home/habridge/x10dim -s A4 255

It may look like a bug to set the value of the module to 255 on 'off' but it isn't. If you think about how X10 works, you can't go from off to a dim setting. You first have to turn the module on, then dim down from 100% (255). So if your light is off and you say 'set lights to 50%' ha-bridge will try to set you to 50%. If you think your previous state is 0 then you would turn on and try to brighten to 50% but you would just stay at full brightness. By setting the previous value to 255, the script will know it needs to dim down from full brightness to 50%.

BobH151 (author)2017-02-14

Can you give an example of a command to do a dim?

JamesB827 (author)BobH1512017-09-30

See my reply above for information on how to implement dim

ellison11 (author)BobH1512017-03-05

I couldn't get dimming to work. If you find out, post!

JamesB827 (author)ellison112017-09-30

I got dim working. The bottlerocket documentation is a little thin in this area but I eventually figured it out. So the basic command to dim or brighten is

br --port /dev/ttyUSB0 -n A4 -d 1

Obviously you replace the port with whatever port are using (I'm on an Orange Pi One using a USB to Serial adapter hence ttyUSB0). The -n is to turn on a module (so substitute A4 with whatever module you are using). Since dim / bright in X10 works on the most recently addressed module, you need to turn on the module first. The -d sets the number of steps up or down (positive numbers brighten, negative numbers dim). In my setup the max number of steps is 7 (from full on to all the way off).

See my comment above for a script that addresses this issue further.

yaiga (author)2017-01-30

Can you use a CM11A in place of firecracker. Because I have a CM11A serial with a serial to usb convert.

ellison11 (author)2017-01-21

Just wanted to leave a little note about shorthand:


br --port /dev/ttyS0 --house=B --on 4
can be simplified to:
br --port /dev/ttyS0 b4 on

Also, I am using a USB-to-serial adapter with my Raspberry Pi and I am having no issues. I used the "TRENDnet USB to Serial Converter, USB 1.1 to RS-232 Male DB9 Serial Cable". I highly recommend this one, since it has been around for a while and is known to work reliably.

ellison11 (author)ellison112017-01-21

A few notes:
-To find the tty address, run "dmesg | grep tty". My address was /dev/ttyUSB0 since I was using the adapter.
-You can just use commands directly in the HA Bridge. So instead of running the script you would do br --port /dev/ttyS0 a1 on

If you have any questions, comment

4wheels (author)2017-01-02

Does the computer i use have to be wireless ?

Grumpus_Magee (author)4wheels2017-01-08

Surely not. Alexa connects to the physical network via wireless,
where your computer hosting HA Bridge is connected. It then sends the wireless signal (radio wireless, not computer network wireless) through the firecracker module to the X10 receiver, which is plugged into the wall. The X10 receiver then relays the signal to the house wiring to control the X10 lamp/appliance modules. The X10 modules
themselves are not wireless.

So as long as all of the components
are on the same physical and logical network, it should not matter. In
fact, I would prefer wired anyway just to rule out possible
connectivity issues that can occur with wireless connections that cannot happen with wired.

4wheels (author)Grumpus_Magee2017-01-10

Hi i try to use the fircracker CM 17A in my older computer that ran my voice control house by voice with all my x10 devices it's still running on widows 95 it wouldn't let me download the program for cm17a are they a nothing way to get to work with Alexa for all my x10 because i'm prailze from the neck down i'm trying to get all x10 stuff working i can use a hand held to work all my x10 so i know its working here's a picture of my home management system

4wheels (author)Grumpus_Magee2017-01-09

Thanks for the help i'll let you know how it goes

DavidR739 (author)2016-11-25

Hi I'm using Linux Mint and I was able to get all this to work!

A few notes: 1. Make sure you don't have Apache2 Web Server running while you set this up because the HA Bridge also runs on port 80. If you had a Web Server and you stopped it, you will need to go to your History and Clear the Recent History before you can see the Configuration Page of the HA Bridge. 2. I simply typed "localhost" into my browser to bring up the HA Bridge. 3. I needed to mess around with the Firewall before Alexa could see the HA Bridge.

All in all, it took a couple of hours but was I was ecstatic to be able to use all my old X-10 stuff with voice commands from Alexa!

About This Instructable

15,467views

30favorites

License:

More by stuffman:How to Control X10 Devices With Amazon Echo or Google HomeBuild a Home Theater PC from a Broken Laptop and a TivoEasily sync music and podcasts to your Blackberry Storm with Ubuntu
Add instructable to: