' ' PURPOSE: ' ' This script will add useful information to your log file and device ' listings about the status of your motion detectors, including how ' long each detector has been on or off. It also alters the output ' to the web server to make motion detectors easier to understand and use. ' ' INFORMATION: ' ' The numbers in the parentheses () to the right of each "No Motion" ' description displayed on the Devices screen indicates the number of ' minutes that have passed since motion was last detected by that detector. ' These numbers are reset each time HomeSeer is started. ' ' SETUP DEVICES: ' ' This script assumes that all motion detectors are on Housecode "B" ' and there are no devices on Housecode "t" or Device "v15". ' ' If your motion detectors are not on Housecode "B", change the variable for ' the Housecode where noted below under "Define Housecode For Motion Detectors." ' NO OTHER DEVICES SHOULD BE ON THIS HOUSECODE EXCEPT MOTION DETECTORS. ' If you do change the Housecode, substitute the new Housecode in every ' instance Housecode "B" is mentioned in the rest of these instructions. ' ' Make sure when set up your Motion Detector Devices that you use ' the correct Location (room name) and Name it "Motion Detector". ' Otherwise, the output of the log file may not make sense. ' ' Make sure that no other scripts, events or devices use Housecode "B", ' Housecode "t" or device "v15". These are all used by this script. ' ' SETUP EVENTS: ' ' [There are two separate events that run this script.] ' ' 1) Set up one event as "Reoccuring" every (1) minute. Have it run this script. ' ' 2) Set up another event to run this script for X10 Command Received "B anything" ' so that all commands from the motion detectors, "B", will run this script. ' ' OTHER INFORMATION: ' ' Help, comments, suggestions are available from bnash@panhandleparadise.com. ' If you use this script, please drop me a line and let me know what you think. ' I am working on a few new features that you may like to know about. ' ' This file was last modified on August 24, 2000. ' (c) 2000 Brian E. Nash, Panhandle Paradise. --- www.panhandleparadise.com ' This script is not warranted or guaranteed in any way. (CYB) sub main() ' ------------------------------------- ' Define Housecode For Motion Detectors ' ------------------------------------- dim hc ' ***** If your motion detectors are on a Housecode other than B, ***** ' ***** change the B on the line below to the correct Housecode. ***** hc = "B" ' ----------------------------- ' Define Variables ' ----------------------------- dim device dim device_count dim k dim t dim xcom, xarray, xhc, xuc ' ----------------------------- ' Initialize Devices ' ----------------------------- if hs.devicestring("v15") <> "OK" then for p = 1 to 16 hs.setdevicestatus "t"&p,"3" hs.setdevicestatus hc&p,"3" hs.setdevicestring hc&p,"No Motion (0)" next hs.speak "Motion Detector Devices Initialized." hs.setdevicestring "v15","OK" end if ' ----------------------------- ' Get Housecode and Unit Number ' ----------------------------- xcom = hs.lastx10 if xcom <> "" then xarray = split (xcom,";",-1) xhc = left(xarray(1),1) if len(xarray(1))=2 then xuc = right(xarray(1),1) else xuc = right(xarray(1),2) k=cstr(xuc) '---------------------------- ' Motion Detected Routine '---------------------------- if xhc=hc then if hs.ison(hc&xuc) and hs.isoff("t"&xuc) then hs.SetDeviceString hc&xuc,"
Motion Detected
" device_count = hs.devicecount for i = 1 to device_count set device = hs.getdevice(i) if device.hc=hc and device.dc=k then hs.writelog "Motion","-------------------------------------------------------------" hs.writelog "Motion","The " &device.location &" " &device.name &" Was Activated" hs.writelog "Motion","Motion Had Not Been Detected For " &hs.devicetime("t"&xuc) & " Minutes" end if next hs.setdevicestatus "t"&xuc,"2" end if '------------------------------- ' No Motion Detected Routine '------------------------------- if hs.isoff(hc&xuc) and hs.ison("t"&xuc) then device_count = hs.devicecount for i = 1 to device_count set device = hs.getdevice(i) if device.hc=hc and device.dc=k then hs.writelog "Motion","-------------------------------------------------------------" hs.writelog "Motion","The " &device.location &" " &device.name &" Is No Longer Detecting Motion" hs.writelog "Motion","Motion Had Been Detected For " &hs.devicetime("t"&xuc) & " Minutes" end if next hs.setdevicestatus "t"&xuc,"3" end if end if end if '--------------------------------- ' Update Detector Off Time Routine '--------------------------------- for p = 1 to 16 if hs.isoff(hc&p) and hs.isoff("t"&p) then t = "
No Motion (" & hs.devicetime("t"&p)&")
" hs.SetDeviceString hc&p,t end if next end sub