X10 Home Automation with heyu and older Macs

X10 Home Automation with heyu and older Macs

This experiment may be of some interest to a small number of XTension users. It’s useful for people who have late model Power Macs that have the original Mac serial ports (the round DIN-8 connectors) that have G3 or G4 processor upgrades. This includes 7500-9500 machines as well as the early Apple G3 boxes (and probably iMacs with serial port upgrades, etc.)

I wanted to find a way to set up a Power Mac 8500 with a G3 processor upgrade so it could run OS X and perform some useful home automation work. The first challenge is getting OS X to run, which is fairly trivial using “XPostFacto”.

I now have a 8500 running Jaguar with the latest Apple developer tools installed. Nice, but no easy way to talk to the old CM11a I have laying around. So I hooked it up to the modem port and searched the net for an old Linux program I remembered called “heyu”.

Turns out that heyu builds just fine on OS X with 2 changes. The makefile craters, but simply typing “./Configure freebsd” on the command line in the heyu directory will generate a proper makefile for OS X. Second, you have to edit the x10.h file and change the location that heyu will use to create lock files. Just change:

#else
#define LOCKDIR “/var/lock”
#endif

to

#else
#define LOCKDIR “/tmp”
#endif

Then you can simply type “make” and get a heyu executable in the local directory. All that’s left to do is to edit the x10config file, changing the TTY definition to “/dev/tty.modem” (or “.printer”) and adding the appropriate unit aliases if you care. Save a copy as “~/.x10config” and you’re done.

The heyu docs talk about issuing a “make install” command as root so the binaries and documentation go to the right places. Don’t bother unless you really want to. From the heyu directory, you can simply enter commands like:

./heyu turn A01 on

and things should work as expected. Where it really gets fun is using the “do shell script” AppleScript command. You can take that command line above and pass it to the “do shell script” command and work the CM11a from good old AppleScript. E.g.,

do shell script “~/heyu.dir/heyu turn A01 off”

I haven’t tried using heyu on a more modern Mac with a USB->serial converter, but I’m guessing that if you can find the right device name in the /dev directory it should all work as expected.

Please feel free to repost this and/or correct as necessary. This took about 10 minutes to figure out and about as long to write up, so it’s certainly not as detailed as it might be.

C.