Messages from Home !
While you are away from your home, your XTension system can send you messages
to let you know that things are OK, or that there is some alert.
Using a simple email program, a modem and your internet account, you can
easily send email to any account, and thus send messages about alerts that
happen in your home. Obviously you can send them to yourself, but you could
also choose to alert neighbors or the police.
Although 'pagers' have been around for a while, the newer 'digital' cell phone
services are offering 'text messaging' direct to your phone. These messages
are sent via your 'email' account, and are sent to you wherever you might be.
In another tutorial we used the YoYo, which doesn't need a modem, but in this case we're assuming that you have a modem available and connected to the Mac.
It may be that you have multiple Macs,
and a network.
More than just cute
Of course you will want the home to alert you in case of any true alarm,
but you also will find it comforting to have it call you occasionally just
to say that things are 'OK'.
You will find that you become quite attached to this concept. Sometimes you
might want to be able to dial-in and tell your system to send you something
like the current home weather report of the time of the last motion sensed.
Other uses are for keeping tabs of children as they come home from school.
They press buttons which signify that they're home, and this can stimulate
a message to you.
Worried that your wife got home? And maybe she just fell asleep before calling?
Just call in and ask for the time stamp of the garage door opener or the proximity
sensor in the bed ?
Again, this is part of the dirty trick of home automation. You have to decide just
how you want your system to serve you.
Getting the pieces together
On the Mac that has the modem directly connected, you should have at least the
basic web connection software, like PPP, and that you have it configured
just like you would when you check your email etc.
We're going to go to the web and snatch some freeware....Since they prefer
that you register for the download, I can't provide it here...
This is MondoMail, and is the cute little app which sends email:
The home page for MondoMail
The other thing you need is the 'plug-in' package that contains all of the rest
of the software that you will need for this tutorial:
Download the plug-in now.
Setting up some things
First, remember always to save-off a copy of your current XTension Database.
It might be that there are some conflicts with names etc. Don't be sorry.
After the package is de-compressed, you will see that there are several files.
One of these files is a standard XTension 'plug-in' file. It contains the units and
scripts that are necessary for this tutorial. While XTension is running, you need
only pull down the "Database" menu and select "Import"... then choose the plug-in.
Another file is the Attachments script. If you do not already have an
Attachments script in your XTension system, then you can just move this file
directly into the XTension folder.
If you already use an Attachments script, then you will want to copy/paste the
handlers in this file into your current Attachments script.
Additionally, there is a little application called NetTime. I believe that
Paul wrote this as a very simple method of getting the current time from a web
'Time Server'. (You can also use another scriptable time-getter called "Vremya".)
You must put MondoMail and NetTime in the startup items
folder of the System Folder on the Mac that controls the Modem. This is because
we want them to be always running and ready.
What's going to happen ?
You must decide just when you want to send a message. Which sensors should cause
a message? How often to just say 'everything's ok' ?
You also need to remember to tell your system that "you are gone" and these messages
In this example, I use a 'flag' named "MF is Gone". When this is ON, or true, it says
that I'm gone and alerts should be sent to me.
Although this tutorial should be complete in most ways, it is up to you to set up
your own 'unit scripts' so that they AlertMe as you choose.
What's going on in the background?
If you choose to use the plug-in as built, then there is a scheduled event which
will periodically "Check the Web".
This global script is included in the plug-in, and will periodically 'tell' the application
"NetTime" to get the current time. If this completes without error, then it is sufficient
data to ascertain that we have a complete connection thru the modem and the ISP to
This maintains both your PPP and modem connections as well as verifies that there is
a 'clear' channel to the rest of the world...just call on the "AlertMe" handler !
If you have your digital cell phone powered on, and you have signed up for the service,
you will quickly receive a 'text' message alert.
In the example I use, it is possible for one of multiple XTension 'hosts' to cause a complete
power-cycle of the 'internet' Mac (Wavey), and correctly re-establish communications
when it completely recovers. This is certainly not necessary, but it shows how you
might establish a set of networked XTension/Macs which behave well together.
Want to see the scripts ?
Here is the 'startup script' for Q800 (change as appropriate). This Mac is a 'backup'
host, and is responsible for both making sure that the Internet connection is 'live',
and for checking on the health of the 'primary XTension host'. (Simpson)
The Attachments Script
Here it is broken into pieces showing the parts we use.
First the WebTest handler which is used to simply test the whole
path from this Mac to 'the Web'.
The AlertMe handler is also located in the Attachments script.
This handler assumes that the path to the Internet is clear and open. You
do not need to keep your internet connection open, but if you have a spare phone line,
then it makes things happen much quicker.
In some of the time trials, I received text messages on my cell phone within 10 seconds
of the X-10 event (more often 20-25 seconds..). Obviously if you have to wait each time for the dialing and connection with the service provider, then your response times will be greater.
Triggered by some event, one of your scripts calls upon the "AlertMe" function to send
some specific message.
The AlertMe handler calls upon "MondoMail" to send the email. This is sent via your
normal service provider, and unless you change the script, you should receive both
a regular email message, as well as a message on your cell phone.
What if you have multiple Macs...?
You do not have to have multiple Macs. This example is just to show that it doesn't
matter. All of the functions, Weather, X-10, Internet and ADB I/O can be located
on the same Mac...although you might need the KeySpan Serial port card if you
want more than X-10 and the Internet on an old SE... :-)
Ok, the startup script kicks off two other periodic scheduled scripts which are
responsible for checking up on the 'primary host', as well as the 'Internet Mac'.
The Internet connection is verified by requesting the current 'time' from some
Web Time Server.
But how do we make sure that the 'primary host' is alive and in control ? We don't
want to take over control of the system by the 'backup host' unless we are certain
that the 'primary' is not functioning.
The most important thing is that the X-10 system is working, and at least is alive
and recording events.
Even though it's important that Apple/EtherTalk is working, it is even more important
that both the 'primary' host and this host have access to the X-10 powerline bus.
In this example, I have chosen to use the X-10 address "A1" to act as the 'hard'
checkpoint between the 'backup' and 'primary' hosts.
The primary host has a scheduled event which really 'turns off' the address via X-10, and the backup host 'sees' this coming in from its interface even though the backup is in 'monitor mode'.
Receiving the "A1 OFF" event is critical to the determination that 'everything's OK'...
And it doesn't matter that much if BOTH of the 'hosts' decide that they are 'primary'
at the same time. It may be that some lamps get brightened a bit much, or that
you get two email messages for each intrusion. That is not a failure...
Within a few minutes, the 'backup' host will notice that the 'primary' host is
physically able to turn off unit "A1", and will put itself into 'backup' mode and
proceed to monitor the health of the 'primary'.
The other side of all this telephony stuff is that you can dial-in and give
commands to XTension!
Be sure to see the tutorial about using a "Touch-tone to X-10" controller.
As always, this tutorial should be considered to be 'in-work', and any suggestions or corrections are encouraged...
Copyright 2007, Sand Hill Engineering Inc. All rights reserved.
Last modified: July 1, 2007
Michael Ferguson, firstname.lastname@example.org