Triggering emails from Geofences

Posted on
Tue Dec 01, 2015 10:04 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Triggering emails from Geofences

Triggering messages or emails on Geos

There are four fields that should be useful to you as triggers:

    deviceLeft - normally false. Set to true if a device left a geo in the last update

    deviceLeftGeo - displays the name of the last geo left

    deviceEntered - normally false. Set to true if a device entered a geo in the last update

    deviceEnteredGeo - displays the name of the last geo entered

These are the states that I use in the plugin to display tracking information in the indigo log.

Create a trigger with the following properties:

Name of Trigger: Mike Enters GeoFence
Device: Mikes iPhone 6 Plus
Entered? is equal to true

It should look something like this:

Screen Shot 2015-12-01 at 15.45.58.png
Trigger properties (device)
Screen Shot 2015-12-01 at 15.45.58.png (57.97 KiB) Viewed 5414 times


Now we need to create an action for the trigger:

Action: Execute Script (Script & File Actions), Embedded Python

Code: Adjust device Id number to the phone you're monitoring and the email to your address

Code: Select all
dev = indigo.devices[454125269] # Device Id number of target phone you're monitoring
geoEntered = dev.states['deviceEnteredGeo']
targetEmail = 'mike.hesketh@hotmail.com' # Where you want the notification sent
subjectEmail = dev.name+' '+'has just entered '+ geoEntered
bodyEmail = 'This email was sent from your Indigo Server'
indigo.server.sendEmailTo(targetEmail, subject=subjectEmail, body=bodyEmail)
indigo.server.log('email sent')


You'll end up with this:

Screen Shot 2015-12-01 at 15.47.50.png
Trigger Actions
Screen Shot 2015-12-01 at 15.47.50.png (90.56 KiB) Viewed 5414 times


This will send an email with the subject like "Mike's iPhone 6 has just entered Home"

You can also add additional conditions for the trigger if you want to check a single GeoFence or only activate the trigger at night.

Here's an example:

Screen Shot 2015-12-01 at 15.49.06.png
Trigger Condition (Optional)
Screen Shot 2015-12-01 at 15.49.06.png (62.19 KiB) Viewed 5414 times


This will only send an email when enter the Home GeoFence and not any other. Of course I could add an Any clause and list a number of GeoFences that I'm tracking e.g. Home, Work, Gym, etc...

Screen Shot 2015-12-01 at 16.00.39.png
Trigger Condition showing multiple GeoFences
Screen Shot 2015-12-01 at 16.00.39.png (76.1 KiB) Viewed 5414 times


Hope that helps a bit

It's a bit harder to do that with iMessages - it's a feature I'll add to the list as a menu or action command that you can set up. Watch this space

Mike

Posted on
Tue Dec 01, 2015 11:46 am
TOPS offline
User avatar
Posts: 169
Joined: Jun 17, 2015
Location: London, England

Re: Triggering emails from Geofences

:D Hi Mike,

Thank you for the clear and easy (for me :oops: ) instructions

Regards,

Dave

Posted on
Tue Dec 01, 2015 2:37 pm
FlyingDiver offline
User avatar
Posts: 7189
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Triggering emails from Geofences

Might be easier to use a BetterEmail action instead of writing a script.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Wed Dec 02, 2015 2:51 am
TOPS offline
User avatar
Posts: 169
Joined: Jun 17, 2015
Location: London, England

Re: Triggering emails from Geofences

Hi Mike,

Set a couple of Triggers/Alerts up yesterday and they didn't fire....

Any thoughts?

Cheers

Dave

Posted on
Wed Dec 02, 2015 3:21 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: Triggering emails from Geofences

TOPS wrote:
Hi Mike,

Set a couple of Triggers/Alerts up yesterday and they didn't fire....

Any thoughts?

Cheers

Dave


Hmmm - not really although it would probably be better if I changed the field to a boolean rather than text. Let me run a couple of tests to make sure that the field is being properly updated.

Mike

Posted on
Fri Dec 04, 2015 5:00 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: Triggering emails from Geofences

Dave

It seems to work with my set up. It might be triggering but not sending the email. Using BetterEmail might be a better option - it's definitely a good suggestion from FD above. If you want to test if the trigger is firing I suggest that you set it up to send a message to the Indigo Log when a phone moves and you can see what happens then.

Regards

Mike

Posted on
Fri Dec 04, 2015 7:54 am
TOPS offline
User avatar
Posts: 169
Joined: Jun 17, 2015
Location: London, England

Re: Triggering emails from Geofences

Hi Mike,

I done away with the sending of an email and used the Pushover Plugin to send the notifications, this works fine if I execute the trigger from Indigo but in real life it does not seem to fire, maybe Ive got something set wrong somewhere else??? to Recap, I want to get an alert for when a device enters a certain Geo Location, I think the Alert side is sorted, its just the device side....

Cheers,

Dave

Posted on
Wed Dec 30, 2015 11:38 am
TOPS offline
User avatar
Posts: 169
Joined: Jun 17, 2015
Location: London, England

Re: Triggering emails from Geofences

Hi Mike,

Now that Santa's gone for another year, could we get back to other items?....I had this working fine but now its not :( , I just want to send a notification to certain phones via the "Pushover/Beacon Plugin" when chosen IFS Devices enter or exit a specified IFS/Beacon Geo. I had it previously working with Beacon generated Geo's but I would rather have it working via IFS.....

Any ideas??

Cheers,

Dave

Posted on
Mon Jan 04, 2016 10:38 am
Chameleon offline
Posts: 611
Joined: Oct 04, 2014

Re: Triggering emails from Geofences

TOPS wrote:
Hi Mike,

Now that Santa's gone for another year, could we get back to other items?....I had this working fine but now its not :( , I just want to send a notification to certain phones via the "Pushover/Beacon Plugin" when chosen IFS Devices enter or exit a specified IFS/Beacon Geo. I had it previously working with Beacon generated Geo's but I would rather have it working via IFS.....

Any ideas??

Cheers,

Dave


Lol - Yes I'll be looking at other items now. Let's me get back into the swing of things and I'll look at your issue.

Regards

Mike

Posted on
Mon Jan 04, 2016 11:21 am
TOPS offline
User avatar
Posts: 169
Joined: Jun 17, 2015
Location: London, England

Re: Triggering emails from Geofences

Brilliant, cheers Mike

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest