iMsg Sending of Animated Gifs

Posted on
Wed Feb 21, 2018 3:10 am
GlennNZ offline
Posts: 668
Joined: Dec 07, 2014
Location: Central Coast, Australia

iMsg Sending of Animated Gifs

How To:

Version 0.7.6 adds a lastAnimGif Variable to Indigo - this contains the local path of the last create Animated gif. Hence this can be used to send a iMsg when any Camera triggers with the following:

Ok - slightly more complicated than sending a file


Code: Select all
set varValueJson to do shell script "curl -u indigouser:indigopassword --digest http://IndigoIP:8176/variables/lastAnimGif.json"
tell application "JSON Helper"
   set varValueRecord to read JSON from varValueJson
   set varValue to value of varValueRecord
end tell

set theAttachment to POSIX file varValue

tell application "Messages"
   set myid to get id of first service
   set theBuddy to buddy "toemail@address" of service "E:fromemailaddress"
   send theAttachment to theBuddy
end tell


The First 4-5 lines reads the variable from Indigo (using Curl) as no Indigo to Applescript support in 7.2.
It then reads the JSON file with 'JSON Helper' and gets the path.

We then set 'theAttachment' variable to the file itself - this is important.
Next we get Applescript to send the attachment to the Selected Buddy from Local Mac Account.

Hence this script can be called anytime (after suitable seconds of delay) a camera triggered and will serve up the most recent Animated Gif from any Camera!


Glenn

Posted on
Wed Feb 21, 2018 4:26 am
Professor Falken offline
User avatar
Posts: 299
Joined: Mar 29, 2015

Re: iMsg Sending of Animated Gifs

Great. Looking forward to trying this if I can get a new iMessages account to verify for my Indigo machine. It seems to be hanging right now, and the help page says it can take up to 24 hours. Weird. Guess I'll have try later.

Posted on
Thu Feb 22, 2018 7:11 am
CliveS offline
Posts: 477
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: iMsg Sending of Animated Gifs

Well I had a fun day getting this working, it seems my lack of Python is dwarfed only by my huge lack of AppleScript.

In case someone else is in the same sorry state I found myself in a few observations.

I could not understand why I kept locking up Indigo when I ran the script internally...

First, save the script externally and with a .scpt extension (i.e AniGif.scpt), then double click it.

That will fire up Script Editor and that told me I did not have JSON Helper (I did say I was pretty bad at AppleScript!)

Make sure you have a space between password and --digest (Username:Password --digest) I didn't, no wonder Indigo went into spinning beachball mode

Off to the App Store (via a Google for JSON Helper!)

Installed and success but on my various google pages I found how to add text and a .jpg file, well 3 iMessages actually and what I think is an easier way to add the recipient.

Code: Select all
set varValueJson to do shell script "curl -u Username:Password --digest http://192.168.xxx.xxx:8176/variables/lastAnimGif.json"
tell application "JSON Helper"
   set varValueRecord to read JSON from varValueJson
   set varValue to value of varValueRecord
end tell

set targetMessage to "Movement Detected"
set theAttachment1 to POSIX file "/Users/indigo/Documents/Indigo-BlueIris/Front_Door.jpg"
set theAttachment2 to POSIX file varValue

tell application "Messages"
   set targetService to 1st service whose service type = iMessage
   set targetBuddy to buddy "+447441234567" of targetService
   send targetMessage to targetBuddy
   send theAttachment1 to targetBuddy
   send theAttachment2 to targetBuddy
end tell


My thanks to Glenn for this great plugin, I am sure he will add to it in the future but even now it is damn near perfect.

CliveS

Indigo 7.4.1 : MacOS Catalina 10.15.1 : Mac mini Server (Mid 2011) : 2 GHz Core i7. : 8 GB. : 2 x 256GB Samsung EVO SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Thu Feb 22, 2018 9:41 am
Professor Falken offline
User avatar
Posts: 299
Joined: Mar 29, 2015

Re: iMsg Sending of Animated Gifs

Thanks for these tips.

I still haven't managed to get authentication on my Indigo Mac mini's new iMessage account. But I too managed to lock up the machine last night while playing around with the script (was trying to just test using my own appleID). I think I did the same thing as you described and was trying to run it embedded instead of saving outside of Indigo. Glenn's instructions mentioned that I think, so I missed that at my own peril.

When/if I get brave enough to try again (if I can ever get that AppleID activated) these tips will help. I still don't really get the "Service" part of these scripts (and I thought AppleScript was supposed to be easy to read!), but I think I understand what yours accomplishes.

Posted on
Thu Feb 22, 2018 11:52 am
neilk offline
Posts: 238
Joined: Jul 13, 2015
Location: Reading, UK

Re: iMsg Sending of Animated Gifs

And don't forget to add the delay. I am embarrassed to admit it took me a while to work out I was getting the previous animated GIF not the current one as during testing I triggered manually with no real motion. Only when I got a message in the dark, and it was mid morning did I realise my trigger was going too soon :D

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest