The following is a Tutorial for XTension to illustrate setting up the automatic motion sensor reports that are part of X2Web. XTension is the grandfather of all Macintosh home automation programs and X2Web provides a web based interface to your XTension setup.
In XTension version 5.2.3 and newer there is a new way to attach a script to multiple units. The instructions that come with X2Web describe adding a call to LogMotion() in the ON script of every motion sensor unit that you want to log. This can be a lot of work of opening and editing dozens of scripts if you have a lot of motion sensors or other units that you want to log.
XTension 5.2.3 adds a feature to the Group so that whenever a unit that is a member of that group
has it's value changed a handler in the groups ON script named:
This handler can be used anywhere you'd normally have to go through and add the same call or bit of script to a large number of individual units scripts.
Here are the new instructions for logging your motion sensor or other data to the database.
This is necessary so that when you need to stop logging to the database you can simply turn it off. Otherwise you won't even be able to quit X2Web as the script in XTension will keep trying to restart it every time a motion even happens.
on LogMotion( TheUnit, TheValue)
if (status of "Log To Database") is true then
ignoring application responses
try
tell app "X2Web" to log data TheUnit value TheValue
on error
write log "X2Web returned an error when trying to log motion"
end try
end ignoring
end if
end LogMotion
This checks to be sure that the pseudo we created in the first step is turned on before doing anything.
and then has several layers of error handling so that we don't bog down XTension if something goes
wrong in the other app. It is always a good idea to put a try block around things and log errors when
you're talking to other apps. Since there is no return from this that we need to worry about I also added
the ignoring responses block. This means that even if X2web's database gets bogged down or takes a few moments
to log the data XTension will return from that immediately and just let it keep working in the background.
You can name this group whatever you like. On my system it's called Motion Sensors to be Logged.

on GroupMemberChanged( TheUnit, TheValue)
if TheValue is not 0 then
LogMotion( TheUnit, TheValue)
end if
end GroupMemberChanged
Since only On hits mean anything to the motion report generator I don't bother to log Off's from the sensors,
thus the check to see if the value is not 0 before doing anything. You can of course log those offs if you want.
In the case of a security sensor or an altered motion sensor with the dusk sensor hack
you'd want to save the off as well. In that case I recommend a separate group for those without the check for non-zero in the
logic there. That is how I have my own setup.
After this point you can follow the regular instructions for creating a list that contains the ones you want to display in X2Web