Set up home-automation geo-fencing with IFTTT and Gmail
15th November, 2015
In this tutorial we'll set up a recipe on IFTTT to send an email to tell a home-automation system whether we are home or away.
IFTTT is a web service and phone app that allows you to customize actions to events.
You can choose from a series of pre-built triggers, then choose an action to respond to that trigger.
You need to sign up with ifttt.com and install their phone app. You will also need a Gmail account.
Creating your recipe
As an example I'm making a recipe to send an email to my AAIMI home-automation system any time I arrive or leave my home.
What happens at the email's destination is another article in itself, and we'll feature all the details in the upcoming AAIMI Home Automation release.
For now I'll give you a quick rundown on how my system works.
As well as the AAIMI home-control program running 24/7 in the background, AAIMI also has another 24/7 Python program that poll's the systems email address. When an email from my IFTTT geofencing app arrives, this program verifies the sender and sorts the keywords from the email. It then loads these details into a database that is read by the home-control program.
Let's get started.
Log in to ifttt.com and click My Recipes. Click Create a Recipe.
Click the blue "this".
In step 1 you choose a trigger.
Type Android into the search box, and click the Android Location icon when it appears.
Choose "You enter an area".
When the map appears, type your location into the search box and locate your house.
Centre your house in the circle and zoom in to a radius of about 50 metres around your property. The house needs to be centered so you can replicate the overal position for the circle in the matching "away" recipe we'll make later.
Once you are happy with the area, click Create Trigger. If you recieve a warning to choose a larger area for accuracy, zoom out one click at a time and retry until you circle is accepted.
That is the trigger finished, it's time to choose an action.
Click the blue "that".
You'll be asked to choose an action channel. Type Gmail into the search box and click the Gmail icon when it appears.
The first time you use the Gmail channel you will be asked to confirm your Gmail account and allow the action. Once done, you will not need to confirm the account for future recipes
Once you have allowed the app with Gmail, click Send an email.
Now we need to enter the details for the email. This is what your home-automation system will receive.
Enter your target address in the To Address field. In my case the is the email address for my home-automation system.
Enter whatever you wish in the Subject field.
The text you place in the body field will depend on how your home-automation system works.
In my case, I also use emails to issue many other remote commands to the system, so the first word denotes what type of action is required. For occupancy-related emails that first word is occupancy. The other keywords vary depending on the type of action required. For occupancy these variables are the name of the occupant and the event, either "home" or "away".
The last word I include is my passkey, which I create when I start the AAIMI home-autmation system. If the password is incorrect AAIMI will discard the email.
Next, click Create Recipe.
Step 7 is a confirmation screen that allows you to check the details and name your recipe. Give the recipe a unique name and click Create Recipe.
That's the "arrive home" recipe completed. Any time you arrive home an email will be sent to the nominated email address.
The away recipe
To create another recipe for "leaving home", the steps are the same until you get to step 2. Instead of "You enter an area", choose "You exit an area.
In step 3, try to center your home exaclty as you did in the "arrive home" recipe.
When you constuct the email body in step 6, replace "home" with "away".
Receiving the emails
You can see how the receiving end of this works in the latest version of AAIMI Home Automation. You'll also see the many other ways AAIMI uses email for secure, remote access, monitoring and control.
Stay tuned, and leave a comment below if you need any help.
There are currently no comments for this article.
buba _________ 8/02/2017 - 09:22:53am
How about the reverse? How would I set up a recipe like IF=Mail THEN=Maker (make a web request) that points back to my html server, that already knows if it receives a POST web request it executes something on the server side.
Anth _________ 8/02/2017 - 01:37:30pm
I have a program that can monitor and react to emails in my AAIMI home-automation system. The program is called aaimi_email.py and is included in the AAIMI Home Automation setup files.
It skips IFTTT and instead runs a Python Gmail client and monitors incoming mail. It's tailored specifically at AAIMI's home-automation functions, but I could knock-up a stand-alone general-purpose version for you if you like.