SecuritySpy info available to AppleScript
I am working with Applescript again, and I have come to want my script to know which camera had motion trigger it or which cameras are on the full screen mode. Are any variables passed into the script when it is called? I hope to call the same script from multiple cameras. Thank you.
Comments
In the meantime you will have to create a separate script per camera and hard-code the camera number into each script.
There is currently no script to get the list of cameras in full screen mode - the method you would need to use is to remove all cameras and then add just the ones that you want.
Here's an example of what you do in the script:
on run arg
display alert "camera number " & item 1 of arg
end run
Your script now goes between the "on run" and "end run" lines, and the "arg" parameter takes on all the arguments passed to the script, the first (and currently only) of which is the camera number. The above script simply displays an alert with the camera number.
For anyone else following this thread, this will be added to SecuritySpy in the upcoming 3.4.2 release.
Hope this helps.
Also make sure to quit your old version of SecuritySpy, download the beta version that I linked to in my email, and copy it to your Applications folder, replacing any older version you have there. Just so that there's no confusion as to what version of SecuritySpy you are running. If you "Get Info" on the SecuritySpy app in the Finder you should see that it's version 2.4.2b2.
That's the error I get when I copy and use your code directly. I've seen a couple other errors trying some changes, but I cannot get any data out of 'arg' or 'item 1 of arg' or 'contents of' stated items. It did tell me at one point 'item 1 of arg' has no value. I think I am testing that arg is not empty though. Indeed I am triggering the script from SecuritySpy's motion detection, and I have verified that the beta version is what is running.
display alert "camera number " & arg --removed 'item 1 of'
end run
This results in an alert that says "camera number current application".
I'm not sure why AppleScript has this limitation but there you go. So save it as a script to SecuritySpy's Scripts folder, set it to trigger, and then you should see that the camera number coming through.
I am making a script which will say the camera name currently triggered and add it to/display the full screen mode. Then it averages motion checks over a pre-set delay before it removes it from full screen mode if the motion is less than a pre-set threshold. Oftentimes, there is still motion on the previously triggered camera when it's time to add a new one to full screen. I have my script checking if the computer is idle to determine whether to wake the display, bring SecuritySpy to the front, or sleep the display. I am attempting to do it all with one script for all cameras, and though I am facing some hurdles, it is working pretty well. I've found a need for the previous triggered number as well as the time it occurred to ignore it if it's older. I'm currently achieving this with a text file.
For example, a car visiting my house will trigger a road camera, then a gate camera, then a driveway camera, so I want to display them then remove them from full screen mode, consecutively and programmatically as the motion comes and goes.
I've uploaded a new beta (to the same location) that includes the camera name as the second parameter - I hope this helps. I'll see if I can add the previously-triggered camera as an additional parameter soon.
I implemented the second parameter without a problem.
I have been successful in creating a text file with the triggered camera number in it so that effectively gives me the previously triggered camera number and the file's modification date will give me the time of that event. Now I am trying to discover how to compare that time with the current time to determine if it occurred in the most recent five minutes or so. The last triggered parameter is only necessary with another parameter that gave me an easy way to do that like the current time in seconds. Feel free to suggest a different route, I am figuring this out as I go.
Thanks for all your help.
SleepDisplay
http://www.malcolmhall.com/products/sleepdisplay/
script
http://pastebin.com/9iNbj4id
text file
http://pastebin.com/K0jKV8Xg
I hope this gets you going.