MacDevCenter    
 Published on MacDevCenter (http://www.macdevcenter.com/)
 See this if you're having trouble printing code examples


Home Automation with Mac OS X, Part 2

by Alan Graham
02/20/2004

The first article in this series focused on the basic equipment you'll need to set up a home automation system. In this installment, I'm going to dig deeper into the hardware and show you some tips I've learned from my experiences.

Before I do that, however, I want to address some of the questions that arose form the first article. So let's start with a quick Q&A.

Home Automation Q&A

Q: What about cost? Could you give us an idea of how much it cost for all your home automation?

A: I have quite a large system. However, let's just look at the backbone of my system as it pertains to this article:

Using a combination of eBay and the X10, Smarthome, and Perceptive Automation sites, I found that I could buy all of these items for about $430. Your mileage may vary (your needs may also be less/more than mine). I would also like to point out that Smarthome manufactures a number of X10-compatible devices that are not only affordable, but also more versatile than their X10 counterparts. I'm focusing more on X10-branded components, because that is what I have.

Q: I have had a terrible time with X10 gear. The controllers and wall switches frequently stop working; lights turning themselves on and off and so on.

A: More often than not, this is caused by line noise or appliance interference. If you find this problem exists, try using a noise filter, like the Smarthome FilterLinc.

Related Reading

Hardware Hacking Projects for Geeks
By Scott Fullam

Other reliability issues can be caused in larger homes. When X10 signals travel through the house, they tend to go everywhere, and not directly to the intended receiver. Along the way, the signal becomes weakened. Try using a Smarthome BoosterLinc to fix this.

Q: I would love to set up my home with this stuff, but I do not care to dedicate a computer to the monitoring of it. Is there such a critter as an intelligent interface that can handle timed events and such?

A: There are a number of solutions for this. X10 has an affordable device (the CM-11) that can "store" schedules and macros, and run them without a dedicated computer. However, this device is serial, not USB, and thus requires a serial adapter (an additional expense). It also has very limited controls (no conditional logic). Indigo can control the CM-11, but cannot upload macros and schedules to it.

Q: I'm curious to learn if you can set up a simple security and monitoring system for the home that can let me know whether somebody has tried to enter our house while we're away on vacation or at the office?

A: There are a number of ways you can do this. I'll cover it in a future article.

Q: I've heard a lot about home automation, but it always seems to be for a 110V environment. I am wondering what tools to use in a 240V environment. Can I use the gadgets you suggest in my 240V home? If not, what substitutes are available?

A: While the devices and the home I am describing are 120V, you can find X10 240V alternatives. The names might be different, but the functionality is the same. Try looking here:

Q: I really like the idea of some home automation, but I would also like to add some data collection and reporting. For example: fuel level in an oil tank (or propane), fuel consumption rates, temperature levels in various rooms or areas in the house, measuring electricity usage at various circuits, etc.

A: I'll cover a lot of this in future articles, including the use of a database to track and control your home, based on calculations. In the future, we'll also build a touch-screen kiosk version of our home automation solution.

Q: Do I need home automation software for a basic solution?

A: No. X10 modules can work independently of a computerized solution; however, your level of control is severely hampered. While you can dim and control the on/off effects of appliances and lighting, there is no conditional logic. So, for example, you could not designate a setting such as:

If sunrise = yes, turn on devices A1, A2, and A3. Dim A3 to 50%

Configuring a Home Automation System

Now it's time to start designing a solution from the ground up. In this article, I'm going to focus on hardware. In the next installment, I'll cover the software aspects. But before doing any of this, I want to take a moment to discuss how X10 technology and home automation works.

X10

The X10 technology is surprisingly elegant and simple in its design and execution. Every module has a house code (A-P) and an individual unit code (1-16). By assigning each module a specific house code and unit code, you are able to designate which module will respond to which signal. These signals travel over your home's existing wiring, so you don't need to retrofit your house.

Let's look at some examples of how this works.


Example 1: Basic Transceiver Setup

In this example, the wireless remote sends out a signal that tells module A2 to turn on. The RF signal is picked up by the transceiver, which in turn sends the signal A2 On across the electrical wiring in your home. When module A2 hears the command, it turns the lamp on.


Example 2: Basic Indigo/PowerLinc Setup

The Indigo software is set up to automatically turn device A2 on when the sun goes down. At sunset, it send the signal A2 On to the PowerLinc USB device, which then sends the same signal through your wiring to the lamp on A2.


Example 3: RF/Indigo/PowerLinc Setup

The wireless remote sends the RF signal A2. The transceiver takes the signal, converts it, and sends it through the wiring. The PowerLinc device hears the A2 signal and passes that info on to Indigo. Indigo knows when it receives the A2 command to turn on lamp A6. Indigo tells the PowerLinc device to send out A6 On.

It is important to note that transceivers, regardless of their house code setting, are always unit 1 To increase their usefulness (and thus not lose a number), you can plug a small appliance or non-dimmable light into the transceiver.

Designing A Solution

In deciding how your system should work, it is smart to plan ahead and think of the areas you wish to control. I like to think of them as zones. It helps to sketch these out on paper before you purchase your X10 equipment.


Four-one Solution

In the above illustration, we have the first floor of a house, divided into a number of different zones. Each zone has a different house code. You wouldn't necessarily configure your home this way (it's not efficient), but this makes for a good example of all of the possibilities.

Entryway: House Code A

In the entryway, we have one light, so one unit code. Very simple.

Living Room: House Code B

The living room has four lights, all with different unit codes. This allows you to control each light individually. You can also control all of the lights as a group, using home automation software. This gives you a wide variety of lighting configurations and effects.

Dining Room: House Code C

All of the lights in the dining room must be controlled as a group, since they all listen for the same house/unit code. You might use this for a combination of chandelier and track lighting. The problem is that you cannot control any of the lights individually, which could be a problem if one of the fixtures cannot be dimmed.

Kitchen: House Code D

This combination might be used for an overhead light fixture, in combination with track lighting or under-the-cabinet lights. For example, you might have a setting that turns on all of the lights to 100% for "cooking," while a "night light" setting automatically turns off the overhead lighting and dims the cabinet lights later in the evening.

Again you don't necessarily want to have each room on a separate house code. For one thing, each house code requires a separate transceiver (for RF control), so your cost goes up. Secondly, this adds a level of complexity when it comes to using remotes. Lastly, you can control up to 16 devices for each house code. That's a lot of items.

My Home


My Home's First-Floor Zones

Here we have four zones on the first floor. Two of these zones are on the same house code, while the remaining two have no home automation at all (we never use the dining room, and the kitchen has ceiling fan/wiring issues). There are six lights with controllers and one appliance with a controller (the fountain in the back -- A8 -- is not pictured). There is one motion detector on the stairs. Using the single house code, in conjunction with the Indigo software, all of the downstairs lights can be controlled by the Slimline wall switch, the TV remote, and the keychain remote.

Entryway Modules and Controllers

Porch lights: both porch lights are controlled by one wired wall switch (A1).

Stair light: controlled by one wired 3-way wall switch (A10).

Slimline Switch: on the wall (controls A1, A2, and A3).

Motion detector: mounted on the wall going upstairs (controls A10).

Also useful here is the keychain remote (controls A1 and A2).

Entryway Commands

A1: Front Porch Lights Only

A2 "Home": Indigo turns on porch lights, living room lights, stair lights, and upstairs lights.

Living Room Modules & Controllers

Transceiver: nothing plugged into it. (A1).

Floor Lamp: controlled by a screw-in module (A5).

TV Lamp: controlled by 2-way lamp module (A6).

Table Lamp controlled by Socket Rocket (A7).

Living Room Commands

A3 "Watch Movie": Indigo turns off A7, dims A5 and A6 to 25%.

A4 "Go To Bed": Indigo turns off A7, dims A6 and A5 to 50%. Turns on A10, A12 (upstairs). Timer is enabled for five minutes, which then turns off A5 and A6.

As you can see, by using one house code downstairs, I can effectively control everything in those two zones individually and through the Indigo software.

Installing Home Automation

Now we finally get to roll up our sleeves and play with some of this hardware. Let's start with the mandatory tools list.

What You'll Need:

Test Your Home

The first thing I suggest when installing your solution is to do a very basic test.

Step 1: Plug in a Transceiver

Find a location in your home to place a transceiver. Leave the default house code set to A.


My "A" Transceiver Resides Behind the Living Room Couch.

You'll notice that these modules are major space hogs. I have three solutions for this. One is a simple six-in-one plug adaptor that simply plugs into existing outlets and replaces the normal switch plate. You can also buy short "pig-tail" cables that plug into the outlet and allow you to plug the module into its cable. You can also use an extension cord.

Step 2: Modules

Take a number of lamp/appliance modules (perhaps three) and set their unit codes to A2, A3, and A4. You'll find the flathead screwdriver works best to switch the codes.


A Flathead Screwdriver Makes Changing the House/Unit Codes a Snap

Next, plug your lamp modules into different lamps in different rooms around the house. This will not only help to test for phase problems (signals having trouble crossing one leg of a home's wiring to the other), but also will help to test the signal strength of the transceiver/remote. For example, my downstairs A1 transceiver cannot hear RF signals from the second floor of the house (this can be fixed with Indigo).


Test Your Solution

Step 3: Try it

First, try pressing the "A1" command and listen to hear if the transceiver clicks on/off. Then walk around the house, testing your lamps/appliances, to ensure that your equipment is working.

Troubleshooting

If you find that your transceiver is not responding and none of your lamps are turning on, double-check your house code settings. Also, make sure the batteries in your remote are fresh and your light bulbs are working.

If one light turns on, but others in the same room do not, try moving your transceiver to the same outlet as the lamps that aren't responding. If the lamps turn on, odds are you have a phase problem in your home. You'll need the Smarthome Phase coupler.

Be sure you verify which type of plug your dryer uses before you order!

If your lights are turning on and off by themselves or are behaving erratically, you may need to purchase a Smarthome FilterLinc.

Continue with the Installation

Once your test is working and you've ironed out the bugs (if you have any), install the remaining components.


Behind the switch plate: The wall switch on the left controls my porch lights. The one on the right (3-way) controls the stair lights.

Wall Switches

These are a little larger than most light switches. If you have installed dimmer switches in the past, you know that they can be a tight fit in the wall, especially if you have multiple X10 switches. It is important after installing these switches to leave the switch plates off until you have verified that they are working properly and you have finalized their unit numbers. Otherwise, you will be removing the switch plate more often than you would like.

Safety note: when installing any type of X10 wired solution, I cannot stress enough the importance of prior wiring experience and proper safety procedures. You should be sure to turn the power to the switch off at the source (breaker). If you aren't sure the power is off, you should use a multitester to verify this. A simple slip of a screwdriver can melt the screwdriver's steel. Imagine what it can do to your body.


Slimline Wall Switches Can Be Placed Almost Anywhere

Slimline Switches

There really is nothing to installing these wall switches, as they do not use any wiring. They operate on a simple watch battery and send RF signals to the X10 transceiver. The basic switch controls any house code you desire, but can only control unit codes 1, 2, and 3. A nice feature with the Slimline switch is that it can dim lights. The switch has self-adhesive tape on the back that is used to mount to your wall. You should clean your wall thoroughly before you attach it. Also, if you have a high-gloss wall finish or high humidity, it may have trouble sticking. I suggest using a silicon-based adhesive, like E6000. This way you can remove it later and it should peel off with no trouble (just be careful with the torque).

Motion Detectors

Installing motion detectors in the "right" location is a process of constant fine tuning. For example, on our staircase going upstairs, we had some difficulty because we didn't want it going off every time you walk past the staircase. It took a few days to finalize the best position for this particular detector. So you want to make sure you don't put the final screws into the wall until the detector works to your satisfaction. Instead, I recommend using tacks, tape, or pins during the testing phase. You might also look into setting it on a surface, like a bookshelf.


Can you see the motion detector? It's hidden behind the framed picture.

Screw-In/Socket Rocket Modules

The screw-in module has some heft, length, and girth to it. This is not for smaller table lamps or floor lamps with small lampshades. It does have a great benefit of being dimmable, and it works well where a plug-in module isn't practical. It can also be used outdoors if it's weatherproofed or installed upside down.

The Socket Rocket module fixes the size issue that you'll find with the screw-in, but cannot be dimmed. It can be used outside if it's weatherproofed or installed upside down. It's easy to program; the unit code is set by simply sending the same code over the house wiring three times in quick succession.


Notice the difference in sizes between a screw-in module, a Socket Rocket, and a regular light bulb.

Appliance Modules

These can be used in a variety of ways. I use one on a fountain, and another on Ikea halogen track lighting in my office. (I may have a few others lying around.) The Ikea lighting uses a transformer that is supposed to mount into a light fixture box or be hardwired onto the wall. I didn't want this ugly thing on my wall or ceiling, so I wired it with a plug and used an appliance module to control it.


This transformer just doesn't fit the look of my house.

PowerLinc USB Interface

Obviously, this has to be located next to the computer with which you wish to control it. Simply plug the USB cable into your computer and then into the PowerLinc module. Then plug the module into the wall. It has an "always on" pass-through plug built into it, which is handy.


PowerLinc module. The USB cable comes out the bottom, while the plug has a built-in pass through.


My Home Server

Phase Coupler

The phase coupler simply plugs into your dryer's 240v wall plug, and your dryer plugs into the phase coupler. If you do require a phase coupler, you really need to pay attention to which shape your house/dryer plug is before you buy the coupler. There are different types of plug configurations. Otherwise, installing the unit is as simple as plugging it in.


Plug the coupler into the receptacle and the dryer into the coupler.

Surge Protection

Like many electronic devices, your X10 components are sensitive to power-line surges. Why just protect your computer or entertainment system, when everything in your home is susceptible to the same danger? Instead of purchasing tons of crappy surge protectors, why not solve the problem at the source?

Think about installing a surge protector at your circuit breaker. While an additional $200+ investment might seem like a lot, it is really no more expensive than many UPS protectors, and covers everything in your house.


Leviton Surge Protector

Next Step: Software

Now that we have the basic hardware down, in the next article, we will start to program our home automation software and see some results.

Alan Graham is the creator of the Best of Blogs book series and is a frequent writer on the O'Reilly Network.


Return to the Mac DevCenter

Copyright © 2009 O'Reilly Media, Inc.