
Two second delay from Security Script
I'm experiencing a 2 second delay from my security devices script that I can't figure out. It's consistent with the MS10As and Door/Window sensors. Here's an example log.
- Code: Select all
2007-01-01 18:48:09 Received RF security command sensor alert (max delay) (ID 43)
2007-01-01 18:48:09 Script Security Device: Kitchen Motion Detector :sec_SensorAlert_max
2007-01-01 18:48:09 Script SetMS10AState: Kitchen Motion Detector sent a alarm event
2007-01-01 18:48:11 Sent X10 "Kitchen Motion Detector" on
The security attachment script operates by changing the state of "fake" X10 devices in Indigo (I betting that one day Indigo will have them in the native UI). Here's the scripts I use:
-- Sample attachment script that illustrates how to listen to
-- commands from security devices. Only the W800RF32
-- interface receives these commands.030515 (mmb)
using terms from application "IndigoServer"
on receive security event of eventType with code devID
if devID is 9999 then
log "Security Device: Garage Door"
SetDoorState("Garage", eventType)
else if devID is 87 then
log "Security Device: Front Door"
SetDoorState("Front Porch", eventType)
else if devID is 169 then
log "Security Device: Front Door"
SetDoorState("Laundry Room", eventType)
else if devID is 202 then
log "Security Device: Small Bathroom :" & eventType
SetDoorState("Small Bathroom", eventType)
else if devID is 43 then
log "Security Device: Kitchen Motion Detector :" & eventType
SetMS10AState("Kitchen Motion Detector", eventType)
else if devID is 2 then
log "Security Device: Guest Bedroom Motion Detector :" & eventType
SetMS10AState("Guest Bedroom Motion Detector", eventType)
end if
end receive security event
on SetDoorState(DeviceName, theeventtype)
set LongDeviceName to searchReplace(DeviceName, " ", "_")
tell application "IndigoServer"
if not (variable (LongDeviceName & "_Last_Open") exists) then make new variable with properties {name:(LongDeviceName & "_Last_Open"), value:((current date) as string)}
if not (variable (LongDeviceName & "_Last_Closed") exists) then make new variable with properties {name:(LongDeviceName & "_Last_Closed"), value:((current date) as string)}
if theeventtype is sec_SensorNormal_min and SubDate(value of variable (LongDeviceName & "_Last_Open")) is greater than SubDate(value of variable (LongDeviceName & "_Last_Closed")) then
set value of variable (LongDeviceName & "_Last_Closed") to (current date) as string
if (on state of device (DeviceName & " Door Sensor") is not false) then set on state of device (DeviceName & " Door Sensor") to false
log "SetDoorState: " & DeviceName & " is closed"
--logmessages("Door", (DeviceName & " Open"), false)
else if theeventtype is sec_SensorAlert_min then
set value of variable (LongDeviceName & "_Last_Open") to (current date) as string
if (on state of device (DeviceName & " Door Sensor") is not true) then set on state of device (DeviceName & " Door Sensor") to true
log "SetDoorState: " & DeviceName & " is open"
--logmessages("Door", (DeviceName & " Open"), true)
end if
end tell
end SetDoorState
on SetMS10AState(DeviceName, theeventtype)
if theeventtype is sec_SensorNormal_min or theeventtype is sec_SensorNormal_max then
log "SetMS10AState: " & DeviceName & " sent a normal event"
else if theeventtype is sec_SensorAlert_min or theeventtype is sec_SensorAlert_max then
log "SetMS10AState: " & DeviceName & " sent a alarm event"
set on state of device DeviceName to true
set on state of device DeviceName to false
end if
end SetMS10AState
end using terms from