Skip to content

AppleScript no longer working to arm/disarm camera?

edited May 2019 in SecuritySpy
Running the latest SS (4.2.10). My AppleScripts are no longer working. For example, to arm specific modes for a specific camera, I had this script...

tell application "SecuritySpy"
set schedule "Armed 24/7" camera number 0 mode Actions
set schedule "Armed 24/7" camera number 0 mode MotionCapture
end tell

This no longer does anything. Maybe the camera number somehow changed? How do I know which camera is which "camera number" for AppleScript (though, I've tried 0, -1, 1, etc. without any positive results)? I tried searching the forums, the AppleScript (Examples) section in SS help, and Google in general and wasn't able to find anything.

Any suggestions?

Comments

  • I am also having issues with applescript not work with my arm/disarm scripts.

    example:

    tell application "SecuritySpy"
    arm camera name "Master Bedroom" mode Actions
    arm camera name "Guest Bedroom" mode Actions
    arm camera name "Upstairs Hall" mode Actions
    arm camera name "Computer Room" mode Actions
    end tell

    The above used to enable Actions, but no does nothing. No errors are displayed.
  • BenBen
    edited May 2019
    This is strange because nothing should have changed in this regard between the previous version (4.2.9) and the current version (4.2.10). I've just tested this with 4.2.10 and can't see any problems, it just works for me.

    The only thing I can think of that could cause this is if you have Schedule Overrides in place, that are overriding the schedules you are attempting to set via AppleScript. Try selecting "Clear All Schedule Overrides" from the Control menu in SecuritySpy, and then trying your scripts again.

    If this doesn't resolve the problem, could you both please grab the previous version and compare them side by side to confirm that there is definitely a difference between versions? You can obtain it here: download SecuritySpy 4.2.9.

    As for the camera numbers, you can get these from the Camera Info window. Click on the header bar (where the column header names are shown) to get a menu to add the relevant column. The camera names will not change between SecuritySpy updates.
  • I downgraded to 4.2.9 and Applescript is working again with that version.

    I then upgraded to 4.2.10 and Applescript is still working. So maybe something went wrong with the original upgrade.
  • Sometimes when there are two versions of an application installed, AppleScript gets confused about which one it should send commands to. Could this have been possible in your case - did you have two versions of SecuritySpy on your Mac? Ideally you should make sure there is just one version of SecuritySpy, in the Applications folder. I can't think of anything else that might have caused this problem.
  • Only one version was installed.

    Just tested and applescript is not working again for 4.2.10. And it's not just getting the camera modes, but any of the SecuritySpy commands.

    For example:

    tell application "SecuritySpy"
    get camera names
    end tell

    Returns: missing value

    If I quit SecuritySpy and relaunch then it starts working again. So, it seems like it may be something occurring after SecuritySpy has been running for some time. I've also tested this on a 2nd mac (view mode) and it too has the same issue.

    I've downgraded to 4.2.9 and will see if same behavior occurs.
  • Hello,

    The same for me with the following script where only the shell script was working (Mac OS 10.13.6, camera D-Link dcs-5020L). it was running perfectly on version 4.2.9 that had been previously deleted:

    property thePath : "http://*****:********@imac.local:8000/++camerasetup"

    do shell script "curl -d " & "'cameraNum=1&transformationMenu=2&mcCaptureMovieCheck=1&frontCheck=1&resetTimeText=5&action=save' " & thePath

    tell application "SecuritySpy"
    ptz preset3 camera number 1
    delay 7
    set sensitivity 50 camera number 1
    set schedule "Armed 24/7" camera number 1 mode Actions
    end tell

    No error message displayed.

    Noting that the new version was not working properly, version 4.2.9 prefs files have been cleared (but I'm nor sure that all prefs files have been erased) and 4.2.10 reinstalled and configured identically but not working again.

    So, I've downgraded (result all Ok) and reinstalled 4.2.10 and this time everything works. There may be something to see there...

  • ! Rectification on what I just posted.

    After a few trials and recommissioning, the same problems reappeared.
    There is surely a little thing wrong somewhere.
    In the meantime I downgrade but Ben will fix it (or see what's wrong with us?).
  • I've been running 4.2.9 for over 24 hrs now and no issues with Applescript.
  • Could you all please try the latest beta version of SecuritySpy and let me know if the problem still occurs? Thanks.
  • No change for me and an error occurred on the following script running 4.2.9 that I had not yet tested:
    ____________________________
    tell application "SecuritySpy"
    open video window camera number 1
    set bounds of first window to {1510, 23, 1920, 365}
    delay 7
    close video window camera number 1
    end tell
    ___________________________

    script error

    Error in SecuritySpy: It is impossible to set window 1 to {1510, 23, 1920, 365}.
  • to complete the previous message: number -10006 from window 1
  • I downloaded the beta and ran it. At first applescript was working, but less than 15 minutes later it then failed. Same issue as before.
  • Just for MacOS reference, on the main SecuritySpy system I am running 10.13.6. On the view only system, 10.14.5. Both experience the same issue.
  • In short, except shell scripts nothing works.
  • Any updates on this issue?
  • Hi All,

    I believe this problem is now fixed in the latest beta version of SecuritySpy (currently 4.2.11b7).

    This fix involved re-writing a lot of the scripting code, so please test your scripts and let me know if you spot any issues.

    If you are using Script Editor, please quit and reopen it after you have installed and opened the beta, so that it can refresh its dictionary.

    @cwibal - opening/sizing windows was never officially supported, so I don't know how your particular script ever worked. However we have now officially added this capability with a new "set window" command. For example, here is how to open and resize the "All Cameras" window:

    set window "All Cameras" x 100 y 100 width 640 height 480 visible true

    Just use the window name to refer to a window (for individual camera preview windows, this is the same as the camera name).
  • SS beta installed 5 minutes ago, for now everything works but I'm still waiting a few hours to restart the tests.
    As for my window management script I simply exploited the dictionary of the application and did a little cooking with some information gleaned here and there and of course, I will try the new command.
    Thank you
  • Well,
    After a few days of use everything works perfectly. It's good to find his little habits.
    Thank you
  • Great, thanks for reporting back!
  • Hi Ben,

    Can you tell me what's wrong with the shell in the script below.
    2 commands don't work :

    soundMenu=Bell ring&¬
    scriptMenu=CamSurChemin

    and I need that to reposition my camera 5mn after a power failure, time to reboot my system with automatic launch of SS and others.

    The script :

    property thePath : "http://Id:Pw@imac.local:8000/++camerasetup"

    tell application "Finder"
    delay 300

    tell application "SecuritySpy"
    ptz preset1 camera number 1
    set sensitivity 50 camera number 1
    set schedule "Armed 24/7" camera number 1 mode MotionCapture
    set schedule "Armed 24/7" camera number 1 mode Actions
    end tell

    do shell script "curl -d " & "'cameraNum=1&¬
    soundSourceMenu=n&¬
    soundMenu=Bell ring&¬
    scriptMenu=Send_iMessage¬
    action=save' " & thePath

    end tell

    Thanks

  • Hello,
    Re-reading my previous post proves that a vacation was well needed.
    So we forget this model of nonsense and I make the thing clear in a future comment.
    With apologies
  • Hi Ben,

    The cleaning was done and the problem remains that in the following the instructions "soundMenu" and "scriptMenu" do not work while "transformationMenu" and "soundSourceMenu" work well.

    My script :

    property thePath : "http://MyId:MyPw@imac.local:8000/++camerasetup"
    do shell script "curl -d " & "'cameraNum=1&¬
    transformationMenu=2&¬
    soundSourceMenu=n&¬
    soundMenu=Hero&¬
    scriptMenu=Send_iMessage&¬
    action=save' " & thePath

    Applescript result : ""

    What can you say about that? Is this an error on my part?

    Thanks
  • The "soundMenu" and "scriptMenu" parameters require the whole file name of the sound/script, including the file extension, which you are omitting in your above script.

    So, for example, if your sound is stored in the file "Hero.aiff" (which is the case for the macOS "Hero" sound that SecuritySpy makes available by default), then you will need to specify soundMenu=Hero.aiff as the parameter and value.

    Likewise, the script file will normally have the extension ".scpt" so you will need to specify scriptMenu=Send_iMessage.scpt for that.
  • Thank you,
    I think I have already tried but it is probably a false memory.
Sign In or Register to comment.