Turn your old Mac into a home-automation system
Automating your home—so the lights turn on automatically when darkness falls, the heat turns on a half an hour before you’re due home, or a security camera watches the house while you’re out—isn’t that hard to do. With a spare Mac and a bit of extra hardware, you can do it in a weekend.
What You Need
The Mac Any Mac that can run Mac OS X Panther (10.3) or later, and therefore has built-in USB ports, is a good candidate. You can use an older Mac, but you’ll also need a USB-to-serial converter. If you’re using OS 9, your software options will be limited.
X10 Modules You need hardware devices to connect your computer to your household appliances. For Mac users, the best choice is home-automation equipment that uses the X10 home-automation standard. While there are other technologies out there, X10 is the most cost-efficient and best supported; because it’s been around since the 1970s, there are plenty of compatible devices.
You’ll need an X10 module for each appliance you want to control. These modules are small boxes, about the size of two decks of cards, that you plug into the wall. You then plug the lamp (for instance) you want to control into the module. Each module is assigned a unique address, which your Mac uses when issuing commands. Those commands travel over your existing power lines. When a module is told to turn on, turn off, or dim a light, it does so by regulating the amount of power going to the lamp.
The best deals on modules are often at X10 Corporation’s Web site, but Smarthome has a larger and more sophisticated selection. Stores such as Radio Shack and Home Depot also usually carry a small selection.
X10 Interface You also need a way for your computer to communicate. Smarthome’s PowerLinc USB ($38) interface is the least-expensive option and a good choice if you want to ease into home automation. The similarly named PowerLinc Controller USB ($70) can also operate in a rudimentary fashion when it’s disconnected from your Mac (if you use the OS X-only application Indigo to set it up).
For people who want to go beyond the basics, the ActiveHome Pro, from X10 Corporation ($49), can also work with wireless modules and security sensors. It’s frequently sold bundled with some X10 modules, which can save you money.
Software OS X users are lucky to have two flexible and well-supported home-automation applications: XTension, from Sand Hill Engineering ($149), has a long history on OS 9 and gives you powerful and flexible scripting options; Indigo, from Perceptive Automation ($90), conforms to the Aqua interface standard and lets you set up common automations without programming. Both work with Tiger, and both are available in free demo versions.
How to Do It
Probably the most common home-automation scenario for beginners is using a Mac to turn on lights, so it appears from the outside that someone is home. Unlike mechanical timers, the Mac doesn’t have to turn lights on at the same time every evening. (You can make the system activate at sunset as the seasons change.)
Let’s assume that you’re using two X10 lamp modules, one connected to a lamp in an upstairs bedroom, and one in the downstairs family room. Their X10 addresses are A10 and B5, respec-tively. You’ve connected your PowerLinc USB or ActiveHome Pro controller to a Mac, plugged the controller into a nearby electrical outlet so it can send and receive X10 commands, and configured either XTension or Indigo to use the controller you’ve selected.
Using XTension First, tell XTension about your lamps. Choose New Unit from the File menu. In the dialog box that appears, give the unit a name and a description. In the Address field, enter
A10. Under Unit Type, select X10; under Dimming Options, select Dimmable. Repeat this process to add the lamp in the family room, but use
B5as the address. Click on OK to finish.
Then create a group that includes both of the lamps you added. Choose New Group from the File menu, give the group a name (such as Sunset Lights), and add the two lamps to the group by dragging them from XTension’s master unit list. Click on OK.
You’ll need to create a scheduled event that turns on the group shortly after sunset. Choose New Event from the File menu. Enter a name for the event, and choose Turn On from the Action drop-down menu. In the All Units pop-up menu, choose the Sunset Lights group. Select the Repeat Every option, and then select Sunset. (XTension uses your system settings to determine your local sunset time.) Finally, select Randomize option and enter a number, such as 15. This will cause the event to occur anywhere from 1 to 15 minutes before or after sunset, so the schedule is less predictable.
After you click on OK, you’ll see the new event in the Scheduled Events window, along with the randomized time that was selected for the next execution. As long as your Mac is on and XTen-sion is running, your lights will come on at the scheduled time.
Using Indigo Select New Device from the File menu. As with XTension, give the lamp a name and a description. Then select Lamp Module from the Type menu, and tell Indigo its address. When you’re done, click on OK and repeat for the second lamp.
Next, set up an action group that will turn both of your lamps on. Choose New Action Group from the File menu. Name the action Sunset Lights; then click on the New button to add the first action. In the Edit Action window that appears, select Send Device Action from the Type menu, choose Turn On under Action, and select your bedroom lamp from the Device list. Repeat these steps to add a second action that turns on the family-room lamp. Click on OK to finish.
Now set up an event that triggers your action group at sunset. Select New Time/Date Action from the File menu. In the Time/Date Trigger section of the window that appears, click on Sunset and enter
13in the Randomize By field. Then click on the Action tab and choose Execute Action Group from the Type pop-up menu. Choose Sunset Lights from the Group pop-up menu and click on OK.
As with XTension, as long as your Mac is on and Indigo is running, your lamps should turn on at the scheduled time.
Gordon Meyer is the author of Smart Home Hacks (O’Reilly Media, 2004).To fool thieves, have Indigo turn on your lights at a different time each night: when you set up a new action, use the program’s Randomize By field to set general parameters.Telling XTension about your lamps is easy: You give each one a name and unique X10 address and then tell the software about its capabilities.