GeoFencing using Find my Friends and Applescript

Posted on
Sun Jan 31, 2016 8:55 pm
jamboinafrica offline
Posts: 16
Joined: Oct 24, 2012

GeoFencing using Find my Friends and Applescript

I have been trying to find a simple way of triggering Geofencing without having to rely on 3rd party apps installed on my iPhone.

The simplest way that I have found so far is to set up a notification to be triggered using the Apple Find My Friends (not technically 3rd Party IMHO) which sends an email to my indigo email address. Using the email polling function or even the push notifications using IMAP have always proved to be far too slow in processing the emails and has meant that I have had to make the GeoFence extremely large to make the triggers worthwhile.

I have found that the quickest way to trigger any event using email is to setup a Rule in apple mail which writes the required information from the incoming email into a variable in Indigo and then using a variable change to trigger any actions. I have found that the response time is measured in a few seconds from the point the email is received and this is adequate for my needs.

The following applescript is triggered when incoming mail meets certain criteria based on selected sender information-

Code: Select all
using terms from application "Mail"
   on perform mail action with messages these_Messages for rule theRule
      tell application "Mail"
         delay 1 -- this delay is included otherwise the script seems to process the previously received email and not the latest one.
         set this_subject to subject of item 1 of these_Messages
         set this_date to date received of item 1 of these_Messages
      end tell
      tell application "IndigoServer"
         set value of variable "messageLast" to this_subject
         set value of variable "messageCounter" to (value of variable "messageCounter") + 1  -- I have a message counter which resets every day to check that all emails have been processed
         set value of variable named "messageLastTime" to this_date as string
      end tell
   end perform mail action with messages
end using terms from


Ideally I would prefer Find My Friends to send a notification to my Mac Mini (which is instantaneous) but haven't investigated this further as the method above is adequate for my needs.

Hope somebody else finds this useful
JIA

PS The additional information that can easily be extracted from the emails is as follows -

id (integer, r/o) : The unique identifier of the message.
all headers (text, r/o) : All the headers of the message
background color (blue/‌gray/‌green/‌none/‌orange/‌other/‌purple/‌red/‌yellow) : The background color of the message
mailbox (mailbox) : The mailbox in which this message is filed
content (rich text, r/o) : Contents of an email message
date received (date, r/o) : The date a message was received
date sent (date, r/o) : The date a message was sent
deleted status (boolean) : Indicates whether the message is deleted or not
flagged status (boolean) : Indicates whether the message is flagged or not
flag index (integer) : The flag on the message, or -1 if the message is not flagged
junk mail status (boolean) : Indicates whether the message has been marked junk or evaluated to be junk by the junk mail filter.
read status (boolean) : Indicates whether the message is read or not
message id (text, r/o) : The unique message ID string
source (text, r/o) : Raw source of the message
reply to (text, r/o) : The address that replies should be sent to
message size (integer, r/o) : The size (in bytes) of a message
sender (text, r/o) : The sender of the message
subject (text, r/o) : The subject of the message
was forwarded (boolean, r/o) : Indicates whether the message was forwarded or not
was redirected (boolean, r/o) : Indicates whether the message was redirected or not
was replied to (boolean, r/o) : Indicates whether the message was replied to or not

Posted on
Sun Jan 31, 2016 10:28 pm
kw123 offline
User avatar
Posts: 8333
Joined: May 12, 2013
Location: Dallas, TX

Re: GeoFencing using Find my Friends and Applescript

May I suggest to give pibeacon a try? Works nicely and is very fast and does not depend on Internet running.


Sent from my iPhone using Tapatalk

Posted on
Fri Mar 11, 2016 4:29 am
121 offline
Posts: 1
Joined: Nov 17, 2014

Re: GeoFencing using Find my Friends and Applescript

I've got trouble executing this script. I don't see any results.
If i try to run this script
tell application "IndigoServer"
set value of variable "myPhone" to "OnMyWay"
end tell
I get error -600 Application is not running
However, the IndigoServer app IS running

Can anyone tell me what i'm doing wrong.
I'm running Indigo 6.1.7

Posted on
Thu Mar 31, 2016 10:03 am
Comgen offline
Posts: 5
Joined: Dec 18, 2015

Re: GeoFencing using Find my Friends and Applescript

I am a complete noob at this, but I did have the same fault and I changed "indigo server" with "indigo 6" and it worked. Just check what indigo is called on your server

Posted on
Wed May 18, 2016 1:06 pm
Different Computers offline
User avatar
Posts: 2533
Joined: Jan 02, 2016
Location: East Coast

Re: GeoFencing using Find my Friends and Applescript

This looks handy.

set up a notification to be triggered using the Apple Find My Friends (not technically 3rd Party IMHO) which sends an email to my indigo email address.


Could you please expand on this? I get how I could set up a notification, but all the options I see for those notifications are Messages, not Mail. While I can, if I think hard enough, start to imagine methods of turning a Message into an email automatically, I bet you have some simple method in mind. How do you make the notification become an email?

SmartThings refugee, so happy to be on Indigo. Monterey on a base M1 Mini w/Harmony Hub, Hue, DomoPad, Dynamic URL, Device Extensions, HomeKitLink, Grafana, Plex, uniFAP, Fantastic Weather, Nanoleaf, LED Simple Effects, Bond Home, Camect.

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests