Tip: text message on motion detection

Richard
edited September 2015 in SecuritySpy
I just wanted to pass on a tip to anyone else who might be interested...

Most cell phone providers have a "gateway" that converts emails into text messages.

My SecuritySpy trigger action uses this to send me a text (with pictures) when one of my cameras triggers. Unlike a regular email, this is much easier to notice on my phone.

I use AT&T, the gateway email there is xxxyyyzzzz@MMS.att.net, where xxxyyyzzzz is the phone number with area code. There are various web sites listing these gateway addresses, here's one of them:

http://martinfitzpatrick.name/list-of-email-to-sms-gateways/

I originally tried to script iMessage, but since I'm logged into the same iCloud account on all devices, sending yourself a message doesn't result in an iPhone notification.

You should be able to use SecuritySpy's native email feature to do this. I used an AppleScript script talking to the Mail app instead so I could limit the alerts to certain times of the day. Here's a pared-down version of my script:

set startTime to "01:00:00 PM"
set endTime to "02:00:00 PM"

if (current date) is greater than date startTime and (current date) is less than date endTime then

set {year:y, month:mo, day:d, hours:h, minutes:mi, seconds:s} to (current date)
set theFile to "/Volumes/blah/" & y & "-" & mo & "-" & d & "-" & h & "-" & mi & "-" & s & ".jpg"

-- If already running, don't send more photos
set myName to "OnBackyard"
set procCount to do shell script "ps axww|grep -e \"osascript.*" & myName & "\"|grep -v grep|wc -l"
if procCount as integer is greater than 1 then
return false
end if

tell application "SecuritySpy" to capture image as theFile camera name "Backyard"
set theContent to "Backyard motion detected"
set recipientName to "Me"
set recipientAddress to "xxxxxxxxxxx@MMS.att.net"
set theSubject to "Camera Alert"
set theAttachment to POSIX file theFile
delay 3
tell application "Mail"
set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
tell theMessage
make new to recipient with properties {name:recipientName, address:recipientAddress}
make new attachment with properties {file name:theAttachment} at after the last word of the last paragraph
set message_attachment to 0
send
end tell
end tell

end if

Hope this helps!

Comments