Home automation – more details

The home automation stuff that I’m doing is mostly X10. There are a few exceptions.

In the garage, laundry, and walk-in closet, I’m using hardware-store-variety motion sensor light switches. They are cheaper than X10 controllers, and are sufficient to the task. That is, I want a light on when I’m there, and not when I’m not. These switches cost anywhere from $10 to $30, and look like this. They work via some unspecified IR sensing, and are very reliable, and very fast.

Everything else is X10. Mostly, it is controlled from my Linux box, so in answer to the earlier question of whether it can be controlled from Linux, YES. There are actually several X10 controller apps for Linux.

You need a X10 transceiver, which plugs into your serial port. There are also USB ones, but I got the impression that they are very new, perhaps not very reliable, and having started using Linux in 1996, I’m always rather frightened of hardware support on Linux.

I am using a command-line app called heyu (pronounced “Hey! You!”). So I run “heyu turn c4 on” and my bedroom light comes on. Or you can alias them, in the configuration file, so that you can say “heyu dim livingroom 11” and it will dim the living room lights by 50%. Yes, it’s a scale of 1-22. I can’t imagine why.

In the bathroom, I have a motion sensor. These send an RF signal to an RF receiver which is plugged in to a wall socket and relays the message. (X10 transmits over the power lines, in case you missed that part.) So when I come into the bathroom, it sends a message to the x10 server, which notices it and runs a script:

#!/usr/bin/perl

# What time is it? 
$h = sprintf  '%02d', (localtime(time))[2];
$m = sprintf  '%02d', (localtime(time))[1];
$t = $h . $m;

# Is it already on?
$on = `/usr/local/bin/heyu dimlevel b2`;
exit unless $on < 20;

# Dim between 21:30pm and 6:30am
# Unless it's already on, that is
if (($t > 2130) || ($t < 630)) {
    `/usr/local/bin/heyu bright b2 8`
} else {
    `/usr/local/bin/heyu bright b2 22`
}

In other words, if it’s before 6:30 am, or after 9:30 pm, just turn the lights on a little bit. Otherwise, turn them on all the way.

Similarly, another script gets called when the sensor doesn’t detect motion for n seconds (60 by default).

One problem with X10 is that it is slow. When I walk into the bathroom, it can take up to 2 seconds for everything to get done and the lights to actually come on. This takes some getting used to. 2 seconds doesn’t seem like a long time, but it *feels* like a long time when you’re standing in the dark.

As for the remote controls – when I ordered my X10 stuff, it came with a universal remote, and one of the things on it is X10. So I can send an on or off, or dim or bright, to any device in a single house code.

The addressing scheme is simple. There are house codes A through P, and in each one there are 16 addresses. So each item in the house gets an address like F2 or C12. This gives a lot of room for devices. However, most transmitters (such as the remote control) can only transmit to a single house code. So you have to plan your addressing carefully.

Anyways, if you want to know more, I recommend buying stuff from PIGS Electronics rather than from X10.com. Better prices, and the website is much much easier to use.

And I recommend the O’Reilly book for good ideas. The implementation is so simple, that the book is really just good for ideas, not really for the implementation details. Also, since almost all of the implementation details are for software that I’m not using, that part of it is not useful to me at all. It assumes you’ll be using Windows or Mac as your controlling computer.