SecuritySpy - Messages.app and iMessage Integration
I've created two scripts that allow you to interact with and control part of SecuritySpy using iMessages and the Message.app
I've tested this on 10.9 and 10.10, but it may work on older versions of Mac OS X.
What can you do with this? You can tell SecuritySpy to send you pictures from your cameras when they detect motion. You can tell SecuritySpy to send you pictures of any camera immediately (regardless of active/passive or motion detection settings). These are the main two features of the package. It also provides some other commands so you can control access.
I recommend you use this with a dedicated SecuritySpy machine ("server"). I made a new Apple ID account specifically for iMessages on this server, and setup Messages.app with this account.
Installation is simple, but requires a few steps. First, make sure you are signed into an iMessage account with Messages and SecuritySpy is running with at least 1 camera.
◆ Copy the file "SecuritySpy Remote Control.applescript" to ~/Library/Application Scripts/com.apple.iChat/
◆ Copy the file "SS_SendiMessages.scpt" to ~/Documents/SecuritySpy/Scripts/
⁃ The ~ means your home folder, usually something like /Users/yourname
◆ Open Messages.app
⁃ Go to Preferences > General
⁃ Select "SecuritySpy Remote Control.applescript" as the AppleScript handler.
◆ Open SecuritySpy
⁃ Go to Settings > Camera Settings > Actions
⁃ Put a check next to "Run Script" then select "SS_SendiMessages.scpt"
⁃ DO THIS FOR EACH CAMERA.
That's it, it's all loaded. Now, from another computer or your phone send an iMessage to this system with the word "cams" - you should receive a list of your cameras. Send "sub *" to subscribe to all of them. Send "help" for help.
Thanks! Let me know how it works for you. And, Ben, I apologize if this is not the correct place to post something like this. I just want as many people as possible to have access to this awesome package.
You can see the scripts (raw) here: http://pastebin.com/anP6Du01
Download them as a package here: http://www.cartcrafter.com/downlods/SecuritySpy_Remote.zip
A couple screenshots: http://cl.ly/image/123A4136352s and http://cl.ly/image/100p3s1z1J0N
I've tested this on 10.9 and 10.10, but it may work on older versions of Mac OS X.
What can you do with this? You can tell SecuritySpy to send you pictures from your cameras when they detect motion. You can tell SecuritySpy to send you pictures of any camera immediately (regardless of active/passive or motion detection settings). These are the main two features of the package. It also provides some other commands so you can control access.
I recommend you use this with a dedicated SecuritySpy machine ("server"). I made a new Apple ID account specifically for iMessages on this server, and setup Messages.app with this account.
Installation is simple, but requires a few steps. First, make sure you are signed into an iMessage account with Messages and SecuritySpy is running with at least 1 camera.
◆ Copy the file "SecuritySpy Remote Control.applescript" to ~/Library/Application Scripts/com.apple.iChat/
◆ Copy the file "SS_SendiMessages.scpt" to ~/Documents/SecuritySpy/Scripts/
⁃ The ~ means your home folder, usually something like /Users/yourname
◆ Open Messages.app
⁃ Go to Preferences > General
⁃ Select "SecuritySpy Remote Control.applescript" as the AppleScript handler.
◆ Open SecuritySpy
⁃ Go to Settings > Camera Settings > Actions
⁃ Put a check next to "Run Script" then select "SS_SendiMessages.scpt"
⁃ DO THIS FOR EACH CAMERA.
That's it, it's all loaded. Now, from another computer or your phone send an iMessage to this system with the word "cams" - you should receive a list of your cameras. Send "sub *" to subscribe to all of them. Send "help" for help.
Thanks! Let me know how it works for you. And, Ben, I apologize if this is not the correct place to post something like this. I just want as many people as possible to have access to this awesome package.
You can see the scripts (raw) here: http://pastebin.com/anP6Du01
Download them as a package here: http://www.cartcrafter.com/downlods/SecuritySpy_Remote.zip
A couple screenshots: http://cl.ly/image/123A4136352s and http://cl.ly/image/100p3s1z1J0N
Comments
I can't download the .zip file though (file not found)- is the link correct?
http://www.cartcrafter.com/downloads/SecuritySpy_Remote.zip
I have a couple questions for you Ben:
1. Is there a way to correlate a camera name with its number? Something like 'get camera number "camera name"' Is what I'm looking for. I would make this script capable of using the number or the name if I had a way to tie the two together somehow. It seems like, via AppleScript, you have to guess at the numbers because there is no "get camera numbers" command like there is for names.
2. The AppleScript examples page only shows examples of how to interact with SecuritySpy externally. There are zero examples on how to use action scripts that get triggered on motion/audio. I had to dig through the bug reports or forums (I forget where I found it) to even figure out we had args (arg 1 for camera number and arg 2 for camera name). Do you have examples or documentation on running a script from within SS? If not, are there other args?
As a feature request I would like to be able to access (and change) things like the following, from within a motion script and/or externally:
- Overlay Text (we have 'set overlay', where is 'get overlay'?)
- Schedule used by a camera
- Available schedules
- Camera Transform settings
- Disabled cameras
- Trigger time
- Camera capture destination
- After action and After Motion settings (seconds)
- Camera groups
- get/set motion capturing or time lapse capturing
- Whether audio support for the camera is enabled and what audio device it uses.
- Captured files, sizes, names, locations, durations (I can tie this data into a custom web service)
- Most of the settings in Preferences.
I don't do a lot of AppleScript, but when I do I tend to cover all the bases. I'd love to see the suite of AS commands available from SecuritySpy mimic what can be done from the web interface.
1. Good point. I have added a corresponding "get camera numbers" command in the latest beta version of SecuritySpy, this should do what you want.
2. This is a relatively new enhancement and hasn't been documented yet, I will make sure to do so. There are currently just the two arguments (camera number and camera name) passed into the scripts that SecuritySpy invokes.
3. Most of these configuration options are available via SecuritySpy's web interface, which can be accessed using AppleScript. See the Camera Settings Change AppleScript example for how to do this. The page only lists a few common settings that you can change, however there are much more - if you load the Preferences and Camera Settings pages pages in a web browser and view the HTML source, you will be able to see all the options (i.e. the names of the controls).
These items are currently not possible to retrieve in a convenient way (i.e. without HTML web scraping):
- Available schedules
- Disabled cameras
- Camera capture destination
- Groups
- Audio device used by a camera
Lists of captured files can be retrieved via XML - let me know if you are interested in finding out about this.
Event: Message Received
File: SecuritySpy Remote Control.applescript
Error: The operation couldn’t be completed. /Users/justin/Library/Application Scripts/com.apple.iChat/SecuritySpy Remote Control.applescript:25873:25897: execution error: AppleEvent handler failed. (-10000)
Any idea?
Rudimentary authentication such as a list of authorized phone numbers or iMessage accounts, stored in a text file on the server, would be an excellent start.
As for authentication: You are correct, anyone with your iMessage account can see "pictures" (not videos) from your cameras. If your account is common knowledge this may not be for you. It suits my needs beautifully and has fit right in with a few of my clients as well. I personally don't care if the Internet has pictures of my porch. It's already a staple on google maps. If you run this at a bank or an adult video store you may want to reconsider.
At some point I will put a bit more work into this. I may add a password feature of some sort, even though I have no need for it. I plan to integrate it with Indigo too, but that makes it less useful to people without that software. I suppose time will tell what my needs are and what I want to do to it.
If you still need help making it work, drop me a line and lets figure it out. frankyhall@icloud.com
I would like to download the script, but the website is down. Could you please give another link?
Thanks
Here are some permanent links from our own server to the above files:
[removed Aug 2015 - please see @frankyhall's github link below]
Thanks for providing this. Would you be opposed to putting these scripts on github?
https://github.com/davidnewhall/iMessageSpy
I'll try to put some time into it, I'm excited that it's under version control. Requests welcome.
I have followed the instructions but I am getting the following error message whenever I send any message:
An error occurred while executing an AppleScript event handler.
Event: Message Received in Active Chat
File: SecuritySpy Remote Control.applescript
Error: The operation couldn’t be completed. /Users/abid/Library/Application Scripts/com.apple.iChat/SecuritySpy Remote Control.applescript:4:5: script error: Expected end of line, etc. but found “<”. (-2741)
m]"
It looks like you have copied the file incorrectly. There should not be any <br /> in it; that is HTML from a webpage.
Replace the file you have at /Users/abid/Library/Application Scripts/com.apple.iChat/SecuritySpy Remote Control.applescript with this:
https://raw.githubusercontent.com/davidnewhall/iMessageSpy/master/SecuritySpy Remote Control.applescript
Hope this helps!
I have replaced the file but now getting the following error:
Event: Message Received in Active Chat
File: SecuritySpy Remote Control.applescript
Error: The operation couldn’t be completed. /Users/abid/Library/Application Scripts/com.apple.iChat/SecuritySpy Remote Control.applescript:31044:31050: script error: Expected “given”, “into”, “with”, “without” or other parameter name but found identifier. (-2741)
Thank you.
"
on received remote screen sharing invitation from theBuddy for theChat
decline theChat
end received remote screen sharing invitation
on received local screen sharing invitation from theBuddy for theChat
decline theChat
end received local screen sharing invitation
"
Bugs that I have seen so far are the following under sierra.
Pics * only send one of my cameras
and motion detection doesn't get triggered anymore.
More testing to be done...
At first I had some issues where it was only responding to the first command and thereafter not responding. Did a bit of tinkering around and also used a separate iMessages account rather than using the same one as on iPhone. It works
How did you figure out to remove those lines? Good work there. I am happy its working on macOS Sierra. I'll see how it goes and report back any issues here.
Pics also sends one image on mine too.
Can't try it on my Lion setup as Lion does not have iMessages.
I'm going to try to fix the case sensitivity problem soon, and I'm planning to install Sierra in a VM today. Hoping to give the code a spring cleaning. Keep an eye on github.
As for making this work with software besides Messages.app: I'd consider coding in Skype support if I had requests for it (I'd use it myself since I already use Skype for video chats with my front door). I'm not sure what Telegram BOT is nor how to interface with it off hand. If you want to amend my code to add new features, I'd be happy to help, but I must ask you to begin the journey for me. Add me on Skype if you want to chat about it. skype://davidnewhall3
I also added a couple other scripts into my github, used for sending security spy pictures or texts from Indigo Actions.
New Features:
- stop command can now stop individual cameras. It can still do all of them too.
- plugin support. You can now write your own small applescripts to use as message handlers. I've included two plugins for demonstration purposes.
- reset feature. This command will wipe out the plist file(s) used by this script. This is useful when you migrate data from one system to another. I also use it to re-run my tests.
- Added an installer script. It's safe to run more than once and should be run every time the code is updated. In other words, run `install.sh` after you `git pull`.
- Make sure you send `reset really` after you upgrade. This will delete the old plist file(s) - those were renamed too. You will also need to subscribe to your camera(s) again.
I fixed nearly a dozen various bugs. Some caused invalid subscriptions and some caused crashing. The script has a new name: iMessageSpy.applescript (instead of SecuritySpy Remove Control.applescript).
Lots of pull request history, code comments and a README update at the GitHub: https://github.com/davidnewhall/iMessageSpy
One last thing, I updated the Restart Messages script to work standalone (without Indigo). This application will prevent Messages.app from getting stuck with a "crash" or "wait" dialog box. Find it here: https://github.com/davidnewhall/IndigoAppleScripts - you'll want to run this if you've ever found Message.app unresponsive due to an error.
Good luck! Please ask questions and report bugs!