Skip to content

customizing PTZ Patrol AppleScript

edited December 2013 in SecuritySpy
Here is a script I am working on. I need some help.



set today to current date
set currentTimeSeconds to time of today

if (currentTimeSeconds > 22000) and (currentTimeSeconds < 63000) then

set thePresets to {"preset1", "preset2", "preset3", "preset4", "preset5", "preset6", "preset7", "preset8"}
set theCurrentPreset to "preset5"

repeat with theCurrentPreset in thePresets

tell application "SecuritySpy"

if ((get motion camera number 2) < 10) then
delay 2
if ((get motion camera number 2) < 10) then

set sensitivity 0 camera number 2



ptz (theCurrentPreset) camera number 2 // HELP- How do I properly pass theCurrentPreset to this SecuritySpy tell?



delay 9
set sensitivity 45 camera number 2
delay 1

end if
end if

end tell

end repeat

end if

Comments

  • BenBen
    edited December 2013
    Hi. The problem here is that preset1 etc. are not strings; they are numerical constants defined by SecuritySpy.

    So you need to surround your whole code block with tell - end tell statements, and define thePresets differently, so your code becomes:

    tell application "SecuritySpy"

      set today to current date
      set currentTimeSeconds to time of today

      if (currentTimeSeconds > 22000) and (currentTimeSeconds < 63000) then

        set thePresets to {preset1, preset2, preset3, preset4, preset5, preset6, preset7, preset8}
        set theCurrentPreset to preset5

        repeat with theCurrentPreset in thePresets

          if ((get motion camera number 2) < 10) then
            delay 2
            if ((get motion camera number 2) < 10) then

              set sensitivity 0 camera number 2

              ptz theCurrentPreset camera number 2

              delay 9
              set sensitivity 45 camera number 2
              delay 1

            end if

          end if

        end repeat

      end if

    end tell

    Does this work?

    By the way, SecuritySpy should automatically disable motion-detection for several seconds after a PTZ command, so you shouldn't need to set the sensitivity to ignore motion as you are doing at the moment.
  • Hi Ben,
    Thanks for the help. That was the key.

    Can you tell me why "ptz preset1 camera name patrolCam" doesn't work? I can only make it work with "ptz preset1 camera number 2" and how do I determine the proper camera number? This is the fourth camera in Video Device Settings... so I expected it would be number 3 (0,1,2,3? Why 2?. One more question. If I save this script as an app and put it in Login Items, what is required to have it exit automatically when I choose to restart?


    I also got some help over at MacScripters.net. I could not paste the current script here, but it is at:

    http://macscripter.net/viewtopic.php?id=41866
  • The camera name will have to be specified as a string, like this:

    ptz preset1 camera name "patrolCam"

    As for the camera numbers, you can see them via the "Device map" window, available from the Window menu in SecuritySpy. Each camera number is assigned when the camera is first set up and thereafter does not change, so unless all your four cameras were set up in sequence, without any cameras being set up and deleted in between, you may not have a continuous sequence of cameras number.

    As for the AppleScript being quit, I think you will need to modify the script to use AppleScript handlers such as "on idle" and "on quit". My AppleScript knowledge runs out around this point - hopefully this will put you in the right direction!
Sign In or Register to comment.