XTension Logo

An Online Tutorial

About motion sensors
(Is someone there ?)

One of the key elements of home automation is the idea of being able to detect (or 'sense') movement in certain places in and around the home, and be able to conditionally react to this information.
This is a multi-part tutorial.
If you want, feel free to skip ahead..."

With XTension, this information can be used to offer automatic lighting effects according to the time of day, or may be used as a reason to issue an intruder alarm, also according to the time of day and status of the home. Perhaps you even want to take a picture of the intruder and upload it to the internet...

There are many more uses, from providing simple lighting at night while you're walking, or when visitors arrive, and even detecting the fact that a child has stayed in the bathroom at night for 'too long', and may be ill or asleep.

With two different sensors together, you can even detect the difference between 'flesh' and 'metal' ! Is it a human or a vehicle that is coming up your driveway?

By choosing the location of a sensor, you can determine whether you want to detect 'short' creatures, like pets, whether someone is moving anywhere in a room, or that someone has passed thru a doorway, or maybe even opened a door or opened your bedroom drawers.

"Is this going to get complicated ?"

There really aren't that many different types of motion sensor, but you wouldn't know that by looking in all of the catalogs. This tutorial should help you understand the basic types, and will describe some of the more common brand-name devices.

From the simplest infrared detectors to the most sophisticated laser beams, they all are intended for one purpose: to detect the presence of some 'body'.

This 'sensing' can be of something that happens at a very specific location (local), or one that occurs within a larger (area).

An Area Sensor
In this example, an outdoor motion sensor detects a 'warm' body moving across an area. It automatically turns on the lights, and sends a message to XTension that 'announces' the event.

A script in XTension may respond to this by speaking an alert, or by turning on the lights, or maybe an alarm.

A local event would be one like someone stepping on a floor mat which had a contact switch in it, walking through a light beam, or driving a car over a magnetic sensor.

An area event would be someone moving within the 'field of view' of a particular sensor. This area is generally known or controllable, but it is large in comparison to the 'field' of a contact switch etc.

In a local case, you know the exact location of the person, but in the case of an area, you don't know, and may not need to care about the specific location.

Note that it is possible to place an 'area' sensor in such a position that it would only be triggered by someone being very close to it, effectively making it a 'local' sensor.

You can mount an 'area' sensor such that it can only 'see' a very narrow and shallow area across a doorway. When it triggers, it says that 'someone has passed into or through this doorway.' Of course you may not know which way they were moving, but with the use of other motion sensors in the home, you can reasonably determine the direction of an intruder. Don't even try it if you have 5 rugrats unless you know that no one is supposed to be at home :-)

Of course you do have to think about house pets, and there are ways of mounting those indoor sensors so that they don't detect the pets moving at the floor level.

What does a motion sensor say ?

How do I tell the 'butler' how to respond ?

Stop and think about it from the point of view of what you would tell the butler to do whenever someone moved in a specific location.

It's really not that confusing. The most difficult part is creating a sentence that clearly says what it is that you want to happen when motion sensor events from 'this' sensor are received by XTension.

Now that may not be so easy. It can be very simple, as in the case of a Hallway Light, but what about the difference between the bedroom and the kitchen, as far as how you would want to manage the lights there ?

You simply create a motion sensor unit in your XTension Database and then create scripts for each of the ON and OFF states of the sensor. These scripts can be very complex, but most often are quite simple.

Of course, you'd start off with things like :
"IF it's between these hours",
"IF the house is empty",
"IF it's dark outside",
"IF no one is in the room",
"IF no one is supposed to be here",
"IF it's the weekend etc...

Whenever XTension receives an ON or OFF message from a (sensor), it will look to see if you have created a script for that condition. If an ON script exists, XTension will automatically perform that script. (ditto for the OFF event)

For example, if you have a motion sensor in a hallway, and you always want the hallway light to turn on when someone is there, then you need only add two units to your XTension Database: "Hallway Motion" and "Hallway Light".

Give it a name, address, and description.

This is a motion sensor. It's not 'dimmable'.

But we might be using the MR26. (RF ok).

Notice that only Hallway Motion needs any Unit Scripts.

A simple ON script for the unit "Hallway Motion" would look like this:

turn on "Hallway Light"

And a simple OFF script for "Hallway Motion" would simply be :

turn off "Hallway Light"

Now that's pretty useless in the sense that if we just assigned the same X-10 address to both the sensor and the light, the light would come on quicker, and we wouldn't even need XTension !

The big Question: Who really turns on the Light ?

If you assign the same X-10 address to both the sensor and the light,
then the commands from the sensor will directly affect the light.

There's no need for XTension to do anything in this case.
The sensor detects motion, the light turns on.
The motion stops, and the light goes off. Great !

Except for one little thing: What about in the Living Room ?
The lights are going to go off when everyone is still for a while...
And you find yourself getting in the habit of waving your arms to get the lights to turn on...:-)

Thus the use for 'scripts' in XTension !

If you give different addresses to the "Hallway Sensor" and the "Hallway Light", Then the message from the sensor would go to XTension, where you could decide just what to do with this 'motion' event.

You may decide that you don't like the hallway light going on and off when you're moving between rooms frequently. So you may want to delay the turn off of the hallway light for some time after the last motion was detected.

If we wanted to simply emulate the automatic behavior of the sensor, except that we don't like the automatic 'turn off' time of the sensor, then we would start with an ON script that looked like this :
turn on "Hallway Light"

And the OFF script would be simply :
turn off "Hallway Light" in 5 * minutes

Now this is also pretty simplistic. It still has 'holes' in the logic that can leave you waving your arms...

So let's think about doing a Hallway Light system that would solve the problem of :

"Turn the lights on if they aren't already on,
and keep them on as long as anyone is here,
and only turn them off if no one has moved here for at least 5 minutes."

Turn Off "in 5 minutes" creates a scheduled event !

In the above example where we said: Turn off "Hallway Lights" in 5 * minutes,
XTension will automatically create a scheduled event that simply 'turns off' the "Hallway Lights" in 5 minutes after an OFF command is received from the motion sensor.

That means that EVERY OFF command creates another one !
So we end up with multiple scheduled events that can turn off the lights ...!

So we need to have some help from the XTension scripting verbs :

How about let's tell XTension that we only want one 'turn off' event to be scheduled for the Hallway Lights at any time..?

The ON script for the "Hallway Motion" sensor could be :

And we don't need an OFF script ! (Thus this works well for the DM10).

As your system matures, and you become more adept at this, you may want to use the "Hallway Motion" sensor as part of your home security system and include a phrase in your ON script which took additional actions if there was no one in your home.

In which case your ON script might look like this:
if status of "House is Empty" is true then
   turn on "All House Alarms"
   (turn on "Hallway Light") -- as above
end if

Now that will work very well for a 'hallway' sensor, but what about something for the Living Room, or the Bed Room ?

The best helper, is something you can call the 'mode of the house'.

You set up 'pseudo' units that can be turned on or off at will. These units represent the 'mode' of something. Like the house. Like "The house is Empty". Or maybe "Weekend Mode" etc.

You can imagine that there are different times of the week when you know that the family is 'in residence', and times when the house is 'empty'.

So you create a New Unit named "House is Empty".

Give that unit an address that can be sent by a wireless remote, or a wired remote (mini-controller) etc. Then any time you send the command that turns on "House is Empty" that mode will be set !

Just use the current status of that unit to help you decide what to do when a motion sensor triggers.

You really have to step back and think about just what you want to accomplish.

Do you want to detect someone opening the door of the beer cooler, someone walking through a doorway, or moving anywhere in a room, or maybe a person in a room, who may have fallen asleep on the couch...? Or even, "is the baby moving in the crib?"

Maybe you want to detect a visitor arriving, or perhaps determine whether the person is coming or going? Or maybe you want to be able to determine whether the visitor is in a vehicle, or walking ?

Is it enough to know that there is some movement in an area, or do you want to know when an object, like a vehicle or human has moved past a specific spot?

What you do with this information is the foundation of the idea of XTension: you can integrate all of the information and facilities that you have available to your Mac or your local network, or even the Internet.

So, you must look at the situation and decide whether an 'area' sensor will do the job, or you must use a 'local' sensor. For this decision, you need to know more about what kinds of sensor are available.

The next page describes the different types of sensors

Back to the Tutorials


Copyright 2007, Sand Hill Engineering Inc. All rights reserved.

Mac Made

Last modified: April 24, 2002
Michael Ferguson, webmaster@shed.com