Building a whole-house X10 controller

Posted by Steve on Fri, 08/25/2006 - 11:10am

X10 transmitters and tabletop controllers are nice but to really explore the potential of X10 you need a central controller. If you've scanned the X10 ecommerce sites you've probably seen a few, along with their frightening price tags. Most of them are basically just PCs running a closed-source application. You've already got a PC so why invest in another one?

There are lots of commercial and open source packages that will let you control your X10 devices from your own PC. These packages range from professional turnkey systems like ActiveHome and Smarthome Essential to open-source, soup-to-nuts hobbyist packages like MisterHouse to Unix command line programs like Heyu and Xtend. The first two packages come with the hardware interface you'll need to link your computer to your X10 network. The rest require you to purchase an inexpensive serial port interface like the CM11A controller.

Commercial packages are really hard to resist, especially for the convenience and their modest cost (under $100). Conversely, open source/free packages can be a real bear to set up, especially for non-techies, and they require your computer to be left on 24/7. The only justification for using something like MisterHouse is if you want the ultimate in home automation and an extendable platform for adding functionality not supported by commercial software. You'll also have to be pretty competent hacker and like spending hours downloading, installing and debugging third-party packages.

I'm one of them, nevertheless MisterHouse was much more program than I needed so I wrote my own X10 daemon based on the Heyu CLI software.

First, install a CM11A controller on a free serial port on your Linux/FreeBSD/*ix box. Note: right there is a good reason to consider one of the above commercial programs because they use the USB port. A lot of modern computers, especially laptops, don't have serial ports.

Next, download, compile and set up Heyu. Your home's X10 configuration is set up in /etc/heyu/x10.conf:
# this file should contain x10 appliance aliases, one per line, as:
#   appliance-name  housecode  modulenumber
# for example:
#  mydesklamp   A       4
#  atticfan     B       3

bedroom_nightstand              A       1
bedroom_ceiling1                A       2
bedroom_ceiling2                A       3
computer_room_cabs              A       5
computer_room_desk              A       6
back_bedroom_sconce             A       8
livingroom_ceiling              A       9
cabinets                        A       10
entryway_ceiling                A       13
upstairs_sconce                 A       14
outside_front                   A       15
diningroom_ceiling              A       16
kitchen_ceiling                 B       1
kitchen_sconces                 B       2
backyard_floods                 B       5
kitchen_ext_spots               B       6
kitchen_ext_sconces             B       7
garage_ceiling                  B       9
basement_ceiling                C       1
dsl_modem                       G       1
wireless_router                 G       2

# set default housecode -- the one the switches will use
# Set the serial port the program will use.
TTY     /dev/cuad0
# The NEWFORMAT directive allows version 1.28 and higher to display more
# informative messages.
# The file listed with MACROXREF is where HEYU will store the addresses
# where macros are loaded in the CM11A.  If you don't use this directive,
# The macros addresses will not be cross-referenced.
MACROXREF       .x10macroxref
Then test the heyu CLI command to see if it's working with something like:
% heyu turn computer_room_desk on
Then, install the perl module Astro::Sunrise and copy this software to
#!/usr/bin/perl -w
use Astro::Sunrise;
use Time::Local;
use Sys::Syslog;

# Config for your house
use constant LATITUDE       => 40.641;
use constant LONGITUDE      => -74.016;
use constant TZ             => -5;
use constant DST            => 1;

# X10 device setup
# Device aliases are set up in /etc/heyu/x10.conf.
# These are the devices we're interested in and how we want
# them controlled.
my @DEVICES = (
    [ 'bedroom_nightstand', 'sunset-45', 'on' ],
    [ 'upstairs_sconce', 'sunset-45', 'on' ],
    [ 'entryway_ceiling', 'sunset-45', 'on' ],
    [ 'outside_front', 'sunset-30', 'on' ],
    [ 'cabinets', 'sunset-45', 'on' ],

    [ 'garage_ceiling', '23:01', 'off' ],

    [ 'upstairs_sconce', '00:01', 'dim+12' ],
    [ 'entryway_ceiling', '00:01', 'dim+15' ],
    [ 'outside_front', '00:01', 'off' ],
    [ 'cabinets', '23:01', 'off' ],
    [ 'basement_ceiling', '00:01', 'off' ],

    [ 'upstairs_sconce', '01:00', 'off' ],
    [ 'entryway_ceiling', '01:00', 'off' ],
    [ 'basement_ceiling', '01:00', 'off' ],
    [ 'computer_room_cabs', '01:00', 'off' ],
    [ 'bedroom_nightstand', '01:00', 'off' ],

$HEYU_CMD   = '/usr/local/bin/heyu turn %s %s';

use constant    SYSLOG_INFO     => 0;
use constant    SYSLOG_WARNING  => 1;
use constant    SYSLOG_FATAL    => 2;

### Program begins ##

openlog "x10_scheduler", "cons,pid", "local1";
syslogger(SYSLOG_INFO, "started");

# Prime today's date
my @last_run_time = localtime;

# Runs until killed with SIGHUP

while (1) {

    @this_run_time = localtime;

    # If the day has changed, reprocess the devices array
    if ($last_run_time[3] != $this_run_time[3]) {

    $time_now = time;

    for (my $i=0; $i 
After you've set up your configuration and X10 events in the program just launch it in the background:
% perl
If you don't know your latitude/longitude you can get it here.

By the way, if you have a real sharp eye you probably noticed the "dsl_modem" and "wireless_router" device aliases in my /etc/heyu/x10.conf file. Both of these are on X10 appliance modules. One of the FreeBSD boxes runs a shell script out of cron which periodically pings a set of IP addresses outside my network. If they all fail, it runs a heyu task which turns them off for 15 seconds and turns them back on again, effectively rebooting them.


Posted by Ian (not verified) on

I've been looking to get into central lighting and home automation but haven't put the time into researching it adequately.

While I'd like to have the expandability of using linux to control the whole system I'll probaby go for a commercial system. I ran a linux system for years but eventually I came to realise that it just sucked away too much of my life. I lost a couple of the hard drives recently and haven't bother to patch the system back up kind of wasteful to leave my computer on 24/7 in anycase.

Even though wireless is nice in an existing home in a new home I'd prefer to go for a fully wired solution. Wireless takes more power and is less reliable than wired. Do you know if instaon has cat5 wired switches? Also I am a little paranoid that someone could just scan the frequency and start messing with my head by turning things on and off from outside my house. I would like to have a remote control that I could use to turn on my lights and being able to ssh into my home machine and turn up the heat would be great too or the cell phone interface you talked about in cases where I don't have computer access.

I would also like to have a central heating system where I could setup profiles and have those profiles used to control each heating zone instead of having seperate programmable thermostats for each heating zone. So I may eventually have to go with a linux solution just to be able to put all the pieces together but what I hope is that a commercial solution will come out that will be equivalent to the linux machine just as hardware routers have replaced the need to use a linux machine to act as your firewall.

ps. you have a great site and I've read all of your woodworking renovation material. Great work!! Keep it up!!

Posted by Steve on

Insteon doesn't support hardwired or ethernet connections. It only communicates on either wireless or X10.

The power consumption of Insteon wireless is really negligible though. The practical range of the transmitter is so low that you would almost need to be in the same room with the switch to intercept a signal from it.

That said, there isn't much in terms of third-party development APIs and hardware for Insteon yet. So you're pretty much married to an M$ software control platform.

Posted by Ian (not verified) on

I'll have to take a closer look at Insteon. I don't really mind being subject to windows as cygwin really helps add enough unix to the os that most things are possible. I still miss my linux box and the sheer flexibility it gave me though. Hopefully I'll be able to just locate some kind of switch which hooks into cat5 and can be sent a signal and then I can just hook those up to a central computer. Surely it can't be that hard to design a switch like that to replace my current light switches.

If you had the chance to redo your floor project would you put a beam and jack posts up while repouring the floor instead of allowing your house to settle and crack and if you did that would it really affect the 3500 psi pour? Seems like there would only be a couple small areas around the jack posts that would not be part of the pour.

Posted by Steve on

A hardwired home automation system would be more reliable than wireless. However, the only hardware I know which uses control line architecture is frighteningly expensive and doesn't use IP either. I priced one of those systems and the wall switches alone ran over $400 and are useless without a five grand-plus, closed-system central controller. And of course, you have to pull all those control wires and home-run them.

What concerned me is what would happen if the company went out of business and I had to replace some of their broken, proprietary hardware.

As for the basement, I spoke with an engineer before I did it and he assured me that I was going to have cracking plaster one way or the other because the house had settled into that slightly sway-backed wood cross beam. That wasn't a large deal because I already had a lot of cracked plaster to repair. It probably added another day or two to those repairs. Since I was doing those repairs it was cheaper than paying a crew for an extra day to pour footings and fit temporary lally columns.