Sound Alarm Remotely When Motion Detected
Comments
-
Hi Geoff,
Here's a good way to do this:
On your desktop Mac (the Mac on which you want to make noise when motion is detected), enable the "Remote Apple Events" option in the Sharing system preference.
While in the Sharing system preference, it will tell you the address of the Mac just under the "Computer Name" box at the top, for example it will say "Computers on your local network can access your computer at: Mac-Pro.local".
On the server Mac, open AppleScript Editor and create an AppleScript as follows:
tell application "Finder" of machine "eppc://Mac-Pro.local"
say "motion detected"
end tell
Obviously you will need to substitute the correct address of your desktop Mac, instead of "Mac-Pro.local" in the above example.
Then run it from AppleScript Editor by clicking the Run button in the toolbar - the first time it runs it will ask for authentication of your desktop Mac - enter this and make sure to tick the box to add the authentication to the server Mac's keychain, so it doesn't ask for it again.
Then save the script to the ~/SecuritySpy/Scripts/ folder (which is within the Documents folder), and set it as an action for any camera you want to trigger it, in the Actions section of the Camera Settings window.
Hope this helps. -
Ben - many thanks for this. Will give it a try.
-
Finally got around to implementing this and it does indeed work. Just one snag - the Security Spy script keeps asking for authentication even though I checked the 'add to keychain' box and tried the passwords for both the server Mac and my desktop Mac.
-
If the password is in the keychain then it shouldn't be asking for it again, so this is a bit strange.
In any case there's a workaround, which is to put the username and password within the address, like this:
"eppc://username:password@Mac-Pro.local"
Does this work? -
Fantastic. Thanks Ben. All working as it should.
But it has exposed another problem. We live on a main A road and headlights on passing vehicles and the shadows they throw, sometimes trip the motion alarm, even though I've got the masking set really tight. Is there any way to disable the script between certain times of day, especially at night? -
Great to hear it's working now. Shadows from moving headlights are bound to set off motion detection, as this looks almost identical to "real" motion from the algorithm's point of view. It is possible to set the AppleScript to limit its action to certain times of the day, like this:
set {hours:h} to (current date)
if h > 8 and h < 18 then
--do something here
end if
This will execute the code between 8 AM and 6 PM. -
Excellent! Thanks Ben.
