AppleScript no longer working to arm/disarm camera?
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?
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
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.
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 then upgraded to 4.2.10 and Applescript is still working. So maybe something went wrong with the original upgrade.
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.
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...
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?).
____________________________
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}.
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).
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
After a few days of use everything works perfectly. It's good to find his little habits.
Thank you
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
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
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
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.
I think I have already tried but it is probably a false memory.