Triggering emails from Geofences

Chameleon
Posts: 611
Joined: Sat Oct 04, 2014 9:50 am

Triggering emails from Geofences

Post by Chameleon »

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:
Trigger properties (device)
Trigger properties (device)
Screen Shot 2015-12-01 at 15.45.58.png (57.97 KiB) Viewed 6401 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 = '[email protected]' # 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:
Trigger Actions
Trigger Actions
Screen Shot 2015-12-01 at 15.47.50.png (90.56 KiB) Viewed 6401 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:
Trigger Condition (Optional)
Trigger Condition (Optional)
Screen Shot 2015-12-01 at 15.49.06.png (62.19 KiB) Viewed 6401 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...
Trigger Condition showing multiple GeoFences
Trigger Condition showing multiple GeoFences
Screen Shot 2015-12-01 at 16.00.39.png (76.1 KiB) Viewed 6401 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
User avatar
TOPS
Posts: 169
Joined: Wed Jun 17, 2015 10:57 am
Location: London, England

Re: Triggering emails from Geofences

Post by TOPS »

:D Hi Mike,

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

Regards,

Dave
User avatar
FlyingDiver
Posts: 7830
Joined: Sat Jun 07, 2014 10:36 am
Location: Southwest Florida, USA

Re: Triggering emails from Geofences

Post by FlyingDiver »

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
User avatar
TOPS
Posts: 169
Joined: Wed Jun 17, 2015 10:57 am
Location: London, England

Re: Triggering emails from Geofences

Post by TOPS »

Hi Mike,

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

Any thoughts?

Cheers

Dave
Chameleon
Posts: 611
Joined: Sat Oct 04, 2014 9:50 am

Re: Triggering emails from Geofences

Post by Chameleon »

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
Chameleon
Posts: 611
Joined: Sat Oct 04, 2014 9:50 am

Re: Triggering emails from Geofences

Post by Chameleon »

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
User avatar
TOPS
Posts: 169
Joined: Wed Jun 17, 2015 10:57 am
Location: London, England

Re: Triggering emails from Geofences

Post by TOPS »

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
User avatar
TOPS
Posts: 169
Joined: Wed Jun 17, 2015 10:57 am
Location: London, England

Re: Triggering emails from Geofences

Post by TOPS »

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
Chameleon
Posts: 611
Joined: Sat Oct 04, 2014 9:50 am

Re: Triggering emails from Geofences

Post by Chameleon »

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
User avatar
TOPS
Posts: 169
Joined: Wed Jun 17, 2015 10:57 am
Location: London, England

Re: Triggering emails from Geofences

Post by TOPS »

Brilliant, cheers Mike
Post Reply

Return to “iFindStuff”