|
|
![]() |
| Product Info | Download | Purchase | FAQ | Support | Company |
Smart Home Hacks Excerpt
We wrote this article for the excellent Smart Home Hacks book by Gordon Meyer. For additional tips, ideas, and hacks to help you boost the intelligence of your home you can purchase Smart Home Hacks on Amazon.com.
Which Way Did She Go?
A hallmark of a good home automation system is the ability to predict what
people are about to need and take care of it for them, such as a light coming
on in a dark room right before a person enters and then turning it off shortly
after she departs. An essential ingredient to this type of automation intelligence
is detecting in which direction she is going. Is she:
Walking up the sidewalk toward the house, or
away from it?
Climbing up the stairs, or down them?
Walking down a hall toward the bedroom, or up the hall away from the bedroom?
This might sound like a complicated problem that would require
video cameras and sophisticated visualization software to solve, but in reality,
you can determine all of these things fairly accurately using two inexpensive
X10 motion detectors.
The trick is to place one X10 motion detector at one endpoint (end of hall,
sidewalk, stairs) and the other detector at the other end. Based on which motion
detector triggers first, the home automation system can make a good guess about
the direction of travel.
For example, consider a hallway leading to a bedroom:

If a person walks down the hall toward the bedroom, the Hallway Motion Detector
will trigger first. At this point, we can predict that someone likely is going
into the bedroom, and we can turn on the bedroom lamp in anticipation of her
arrival. Likewise, when she leaves the bedroom, the Bedroom Motion Detector
will trigger first and the system knows to turn off the lamp.
A person walking in the hallway will trigger both detectors
eventually, so the key here is tracking which detector triggers first. Otherwise,
the light would blink on and off as she approaches the bedroom, and off and
on as she travels away from the bedroom. Let’s look at how to do this
using Indigo for Mac OS X, beginning with turning on the light as a person
approaches the bedroom.
After you’ve added the motion detectors to Indigo’s
device list, create a trigger action that occurs when Indigo
receives an X10 On command from Hallway Motion Detector:

The action for this trigger is a simple two-line AppleScript.
The second line is straightforward; it turns on the bedroom lamp. It’s
the first line that makes this smart. It disables another trigger action (which
we’ll discuss in a moment) for 10 seconds.
This gives the person who triggered the motion detector just enough time to
scoot down the hallway and pass the other motion detector, Bedroom Motion Detector.
That detector still will send a command to Indigo, but there will be no enabled
trigger actions for the command, so no action is taken.
You could replace the AppleScript commands with a two-step action group that
accomplishes the same thing.
Now, let’s set up the trigger action for the Bedroom Motion Detector. As in the previous example, its trigger is the receipt of an X10 On command:

The action for this trigger turns off the bedroom lamp and then
disables the action trigger for the Hallway Motion Detector we defined earlier:

Similar to the technique described earlier, this disables the action so that
it does not occur when the person triggers the second motion detector. As long
as she makes it past the detector within 10 seconds, the bedroom light will
not turn back on.
When you implement this hack on your system, make sure you specify the correct
names of the trigger you’re disabling.
You might need to tweak the 10 second delay so that it works
better in your home. It needs to be long enough for the person to pass from
the view of one detector and into the view of the other. Don’t make the
duration too long, though, or you’ll miss a valid trigger if she reverses
direction quickly, such as running back into the bedroom to grab a forgotten
item.
You’ll need to carefully consider the placement of the
motion detectors. For example, if the Bedroom Motion Detector was actually
in the bedroom and not in the hallway, we would end up turning off the lights
as the person walked around the bedroom. You can place the two motion detectors
fairly close to one another; they just need to be far enough apart that the
closest one will reliably trigger first in both directions.
Finally, as smart as this hack is, it is not perfect. In our example, if two
people enter the bedroom, the lamp will turn off when the first person leaves.
This is not necessarily a flaw in our scheme for predicting a person’s
direction of travel; it’s caused by the fact that this system does not
keep track of how many people have entered a room.
You could, indeed, extend the logic to increment a counter as people enter the room, and decrement it as they leave—keeping the lights on until the counter reaches 0. However, you will likely run into problems with the counter getting out of sync if two or more people walk down the hallway together. Two people passing each other between the detectors also will confuse our simple logic. But despite these flaws, this hack demonstrates that it is possible to create a somewhat intelligent system with a little careful analysis.