Thursday, March 17, 2011

AutomateIt Location Trigger - Tips and Tricks

For Location Trigger tips & tricks visit our new website at this link.

One of the most popular triggers provided by AutomateIt is the Location Trigger.
Although defining such triggers is very intuitive, still there might be some tips and tricks that can make it even better.
This post will walk you through the basic settings of a common location trigger, emphasizing some features that could help you get the best out of this trigger.
Let's start with a quick overview of the different controls on the location trigger configuration screen:

Most of the controls are pretty self-explanatory so I'll focus on the ones that could use some additional explanation:
  • Arrive at location - Notice that the location trigger defines “Inside or Entering” or “Outside or Exiting” a proximity region around a location. if you are inside the proximity region and defining a rule of "Inside or Entering" a proximity region, it will trigger immediately (dependent on other parameters as explained below). Same goes for defining a rule of "Outside or Exiting" a proximity region when you are already outside of that region.
  • Allow Coarse Accuracy/Use GPS - Select the appropriate location providers for your needs. if just a general location is required, it's safe to allow coarse accuracy. If a more accurate fix is required, uncheck this setting and only use the GPS. The level of accuracy for different providers varies significantly depending on available cells in your area, moving speed etc.
    Tip: I use the following guidelines for location provider accuracy (values are based on my personal experience while developing this application):
    • Network location provider (using cell location) accuracy varies from 200 meters to 2000 meters
    • When connected to Wifi network location estimated accuracy is ~100 meters
    • GPS accuracy can be estimated as 3 meters to ~50 meters (especially when you are moving fast)
    • For more details on location providers and fix accuracy, click here.
  • Location Sampling Rate - Sampling rate is the time interval the application wakes up to check the device location.
    Tip: Use short interval to be more responsive at the expense of activating the location provider(s) more frequently, thus, exhausting your battery (especially when there is no GPS reception) or longer intervals to balance your battery usage.
  • Proximity Radius - By default, this is taken from the application settings (see below). make sure you select an appropriate radius as recommended for the selected location providers (as defined for "Allow Coarse Accuracy").
When defining different parameters for this trigger keep in mind that it will be activated once it can be determined with 100% certainty that you are inside/outside the defined region, considering the accuracy level of the fix.
For instance, let's say the proximity radius is defined as 10 meters and the fix accuracy is 40 meters - in such case even if the fix location is exactly the center of the defined region, the trigger will not be activated since it can't be guaranteed that you are indeed inside/outside the defined region.
Tip: Define a proximity radius that is the maximum reasonable for your needs (I use 1500m for "Entering" rules and 200m for "Exiting" rules).

Some of the default values for settings described above can be set from the settings screen:

One setting I'd like to highlight is the "Location Provider Timeout" which defines an upper bound for trying to get a fix. In case the location provider does not get a fix after this time has passed, it will stop trying to get a fix until the next time defined by "Location Sampling Rate".
On the other hand, once a location provider gets a fix, it will not keep waiting until the defined timeout but it will stop immediately.
This is mainly used to conserve battery so feel free to adjust this setting to your needs.
Tip: Don't push this setting too high (could drain your battery) or too low (could be too short to get a fix).

Last Tip: Avoid setting a "Location Sampling Rate" that is shorter than the "Location Provider Timeout". This will cause the location trigger to constantly request location updates.

New Feature on version 1.16.0 - Since version 1.16.0 each rule stores its history so you can keep track of events related to your rules (for more details on this feature click here). Rules with location triggers have a more detailed history log:
This log shows the recent events for the rule "Turn on wifi at home". You can see that all GPS related events are shown in cyan and all network location events are shown in white.
By looking at this log we see that the location trigger requested location update on 20:45:49 from both GPS and network (two bottom events), received location from network provider 2 seconds later and triggered the rule. At 20:46:19, which is exactly 30 seconds after the first event, the GPS timed-out since we didn't receive any location update (I was indoors when creating this demo).
To better understand the "Is Inside Target Region" response which might be Yes, No or Unknown, take a look at the following diagram (click on the image to enlarge):
One Interesting feature is that once a location is received, you can click on the hyperlink (the coordinates on the screenshot are smudged) and show it on Maps application or using the Browser:
This log can be very useful to better understand and fine-tune your location triggers since it shows you each location received, level of accuracy and the distance to your defined location. Here is a list of all events related to location triggers that you might see on your rule history log:

  • Start waiting for location (provider=GPS/Network, timeout=XX)
  • Location received (provider: GPS/Network) - Includes location details
  • Location provider timeout. no location received (provider=GPS/Network)
  • Location provider enabled/disabled (provider=GPS/Network)
Feel free to add more tips and best practices to the comments of this post.