NOTE: There is now an easier way to do this without involving IFTTT and Dropbox. There are several apps for the iPhone now (and probably android too) that do geofencing without all this extra setup. Have a look at the new tutorial here
Knowing if you’re home or not can be very useful information for the HA system to have. Turning off lights, setting alarms etc. There are numerous ways of setting this up all with some drawback or other, this tutorial will discuss using the If This Then That in combination with DropBox to get your iPhone’s presence or absence into a unit in XTension where you can then do whatever else you wish with it. While It does involve 2 other 3rd party services both companies offer free service that is enough to make this work.
The connection to XTension will be through the JSON interface So the first thing you’ll need to do is create a new instance of the JSON interface, allocate a token and create a unit in XTension assigned to that interface. While the name of the unit can be anything, as usual, the address needs to be something simple and discrete. For example “jamesiphone” or “iphone1” or something as this is the data you’re going to be passing from IFTTT. Lastly you’ll need to setup a passthrough on the high port you’ve chosen to run it on through your router or airport or cable modem so that connections from the outside world can reach your XTension machine and have a dyndns or noip.com account configured to let you connect backwards to your machine from outside.
If you dont already have a Drop Box account now is a good time to create one.
Then you’ll also need to create an If This Then That account and download their client. They have both android and iPhone clients and there are similar actions for android location data but I have not tested those.
There are lots of choices in IFTTT, click their large “Create a Recipe” button and then the “THIS” portion of the next screen. For an Android phone you’re looking for the “android location” icon. For the iPhone you’re looking for the blue square with the location services arrow in it called “IOS location”
For iOS you’ll actually need to create 2 recipes, one for entering the area and one for exiting. It should be possible to use the enter/exit and make the term part of the unit address, but as of this writing I haven’t been able to get that to work. Using 2 Recipes works. You’ll now be presented with the choice of “enter an area”, “exit an area” or “enter/exit an area” first choose “enter an area”
Use the geofence map and circle interface to circle your home or wherever else you want to track your presence.
Once thats set, click the “Create Trigger” button and the bit “THAT” that comes up next.
Select the Drop Box icons and choose “Add File from URL” this is how we get this info into XTension. The URL is going to go to the JSON interface you created above.
for “File URL” enter the url to the JSON interface. It will be in the format of:
http://dyndnsaddress.org/[token created on JSON interface/[XTension unit address]/on
or:
http://iamcool.noip.com/14F6A2551298B4C5/iphone1/on
the next 2 parameters aren’t important, File Name and Dropbox Folder Path can be left as the defaults or handled as you see fit.
Now create the action and you’re half way done. Now you need to repeat the creation of another Recipe but this time use the “exit an area” action and the link to File URL should end in /off instead of /on to turn the unit back off when you leave the geofence. Like:
http://iamcool.noip.com/14F6A2551298B4C5/iphone1/off
there are a few limitations. All such background processing times out in a couple of weeks, so it will silently stop checking you in and out if you don’t actually run the IFTTT app on the phone once in a while. This is the same as Prowl so isn’t that much of a hardship.
The other problem is that it does leave behind a tiny 600byte file on your dropbox account. If you open the file it will redirect you to the same link turning your phone status unit on or off as if it were a real event. Once in a while you’ll want to clear out those files but they are small and shouldn’t build up too fast.
Lastly of course is a thought of security. Anyone can make this hit on your server if they listen in on your settings or discover your drop box or IFTTT passwords. Do not rely on only one input for any truly important tasks or be the final word on alarm setting or clearing.