How to Control X10 Devices With Amazon Echo or Google Home

36,298

39

22

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.

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

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?

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!

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

...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!

IoT Builders Contest

Participated in the
IoT Builders Contest

Share

    Recommendations

    • DIY Summer Camp Contest

      DIY Summer Camp Contest
    • Planter Challenge

      Planter Challenge
    • Games Contest

      Games Contest

    22 Discussions

    0
    None
    rickryan86

    Question 6 months ago on Step 5

    I am using my x10 lamp modules and still enjoy them, There has to be a simple way to interface and control these with my alexa DOT as to just say 'alexa cut on my x10 lamps, and there has to be a way to control this from my iphone just like i do now using the tp kasa smart plugs to control my lights from my iphone from anywhere ''with out going through my home computer being on all the time.......please help as i have been loosing sleep over this and need so much to fix this issue.................Rick Ryan in NC

    0
    None
    dye46

    9 months ago

    Warning. This info is 2 years old and has the HA Bridge s/w and user interface has changed quite a bit.

    But in the end I was able to muddle through the clunky interface.

    To turn on the URL text boxes, you need to change the Device Type to Execute script/program and then go to the top and click the Change Edit Mode button.

    For Script execution (you can run arbitrary local hosts scripts, mine were heyu/CM11a wired RS232 X10 home control, but I could run other scripts to change my VLC audio station)

    The script URL is no longer a simple string, it has to be like this:

    [{"item":"/path/to/script",""type":"cmdDevice"}]

    More info here: https://github.com/bwssytems/ha-bridge

    0
    None
    dye46

    Question 9 months ago on Introduction

    I have a linux/CM11a setup using Heyu. Any ideas, is this do-able?

    0
    None
    kmand

    10 months ago on Step 5

    I have it working with a TM751, but have one problem. I have a bunch of lights controlled by wall switches. Wherever I plug in the TM751 one light is missing. If I move the TM751 its a different light that gets missed. All lights on with a standard x10 control box gets them all, not the TM751 whether I use all lights on with BR, or the specific unit number. If I could use two TM751's I would be ok, but apparently the unit number is hardwired. I can hack the br software, but not the TM751 hardware.

    My wiring is old (2 wires) which is the real culprit, but not practical to replace.

    Any ideas?

    0
    None
    ArnoldM31

    Question 10 months ago on Introduction

    Do you have to keep the computer on once everything is setup?

    0
    None
    MarkA344

    Question 1 year ago on Step 5

    I use a cm-19a. Compatible or not. Also have the Trane 850 thermostat. What's my best route to go? Thank you

    0
    None
    rexabbot

    1 year ago

    Please help, I am stuck.

    I get this error:

    java -jar ha-bridge-5.1.0.jar

    Exception in thread "main" java.lang.UnsupportedClassVersionError: com/bwssystems/HABridge/HABridge : Unsupported major.minor version 52.0

    And when I go to http://ipofserver:8080 I get:

    This site can’t be reached

    ipofserver’s server DNS address could not be found.

    0
    None
    JamesB827

    1 year ago

    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.

    2 replies
    0
    None
    Jason BJamesB827

    Reply 1 year ago

    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.

    0
    None
    JamesB827JamesB827

    Reply 1 year ago

    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%.

    0
    None
    BobH151

    2 years ago

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

    3 replies
    0
    None
    JamesB827BobH151

    Reply 1 year ago

    See my reply above for information on how to implement dim

    0
    None
    ellison11BobH151

    Reply 2 years ago

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

    0
    None
    JamesB827ellison11

    Reply 1 year ago

    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.

    0
    None
    yaiga

    2 years ago

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

    0
    None
    ellison11

    2 years ago

    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.

    1 reply
    0
    None
    ellison11ellison11

    Reply 2 years ago

    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

    0
    None
    Grumpus_Magee4wheels

    Reply 2 years ago

    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.

    0
    None
    4wheelsGrumpus_Magee

    Reply 2 years ago

    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

    home automation 004.JPG