Discriminate in Actions Script 'ON Motion' from 'On Triggered'
Guarding a dwelling perimeter, I'm running motion detection on two cameras, one camera triggers the other on detected motion and vice versa. The camera that detects motion runs an Actions script to trigger Home Automation (using an XTension alarm Unit) that motion is detected and triggers via the camera setting its adjacent camera(s).
Unfortunately, the camera that is triggered by an other one's motion, also runs the same Actions script, as if it itself has detected motion. Therefore, two Home Automation alarm Units trigger and I'm not able to tell which camera was motion triggered.
(In XTension one can block unit ON scripts for a set amount of time. My first attempt was to let camera one ON script block camera two ON script for a while, as triggers during blockage are skipped, not delayed. Action reporting is so fast however that blocking occurs only áfter the second camera has triggered the second unit. Thus I can't prevent motion triggering being reported by both cameras.)
Complicating factor may be that the second camera is already triggered by the first camera and then itself detects motion. In that case, I like to signal that motion as motion detection (and extend the recording time of the first camera by triggering it).
How can I discriminate in an Actions Script the 'Trigged By Motion' from the 'Triggering By Other Camera'?
Unfortunately, the camera that is triggered by an other one's motion, also runs the same Actions script, as if it itself has detected motion. Therefore, two Home Automation alarm Units trigger and I'm not able to tell which camera was motion triggered.
(In XTension one can block unit ON scripts for a set amount of time. My first attempt was to let camera one ON script block camera two ON script for a while, as triggers during blockage are skipped, not delayed. Action reporting is so fast however that blocking occurs only áfter the second camera has triggered the second unit. Thus I can't prevent motion triggering being reported by both cameras.)
Complicating factor may be that the second camera is already triggered by the first camera and then itself detects motion. In that case, I like to signal that motion as motion detection (and extend the recording time of the first camera by triggering it).
How can I discriminate in an Actions Script the 'Trigged By Motion' from the 'Triggering By Other Camera'?
Comments
"Three parameters are passed to these scripts:
The camera number
The camera name
The reason for the trigger, which is a comma-separated list of the following reasons: Motion,Audio,Script,CameraEvent,WebEvent,OtherCamera,Manual,Human,Vehicle"
Here's how you would test for a certain trigger type in your script:
on run args
set reason to item 3 of args
if reason contains "Motion" then
--Do something for motion trigger
else if reason contains "OtherCamera" then
--Do something else for other cam trigger
end if
end run
It was the "on run args" construction that I was after, and how to fish the reasons from the pond of text.
Just what the doctor ordered.
Thanks Ben.
on run args
set reasonValue to 0
set reason to item 3 of args
set cmdstring to "echo " & reason & " > " & "/Users/me/Desktop/catcommand.txt"
do shell script cmdstring
end run
The file is indeed created, but to my great surprise it contains this single line:
Motion,Audio,Script,CameraEvent,WebEvent,OtherCamera,Manual,Human,Vehicle
I don't see how that can be on a Motion Detection Actions ?
if reason contains "Motion" then
--Do something for motion trigger
else if reason contains "OtherCamera" then
--Do something else for other cam trigger
end if
Or do I misinterpret your question?