Minimum precision filter for Location trigger

Post your feature requets for new triggers, conditions, actions and other improvements.

Moderator: Martin

Triangulix
Posts: 10
Joined: 20 Sep 2014 21:17

Minimum precision filter for Location trigger

Post by Triangulix » 20 Sep 2014 23:05

Hi

Normally my location is detected very precise. The map even shows in which part of a building I am. But a few times a day the location service seems to have a hick-up that makes my position jump to the next GSM station, stay there for a few moments and then jump back to the correct location.

Since the false location is always associated with a huge radius I almost solved this problem with the minimum precision filter in the Periodic Location Update trigger. Unfortunately this filter only exists in the Periodic Location Trigger and not in the Location trigger. Using the Periodic Location Update trigger I had to combine all location based decisions into one huge ruleset. It could be much simpler if I could use the Geofence based Location trigger and one ruleset per location while ignoring all Geofence events associated with a large radius.


Triangulix

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Minimum precision filter for Location trigger

Post by Bushmills » 24 Sep 2014 13:28

+1

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Minimum precision filter for Location trigger

Post by Martin » 25 Sep 2014 14:22

Hi,

The regular Location trigger uses the API offered by Android to handle Geofences which does not allow to define a minimum radius. You could switch to the Modern setting to see if Google has improved their algorithm in the newer API and ignores such cell phone locations better.
Using Periodic Location Update in conjunction with a condition Location with Entering or Exiting checked should work more or less the same like a Location trigger that supports the minimum radius and should not complicate the flow a lot. You would have to create a condition for each location instead of creating one trigger for each location. I admit that the flow looks a bit bigger since the conditions are visible as distinct objects and not just one rectangle like the triggers.

Regards,
Martin

Triangulix
Posts: 10
Joined: 20 Sep 2014 21:17

Re: Minimum precision filter for Location trigger

Post by Triangulix » 26 Sep 2014 16:27

Hi Martin
Martin wrote:Using Periodic Location Update in conjunction with a condition Location with Entering or Exiting checked should work more or less the same like a Location trigger that supports the minimum radius and should not complicate the flow a lot. You would have to create a condition for each location instead of creating one trigger for each location. I admit that the flow looks a bit bigger since the conditions are visible as distinct objects and not just one rectangle like the triggers.
That is what I did and what I tried to describe as my workaround.
Yes, the flow becomes huge and complicated not only because of the enter and leave conditions for every location but also because I had to combine all location based actions into one flow. It even got more complex as I had to add a few WiFi checks to increase the precision in an area where the Google map seems to be a bit off. Combining location and WiFi conditions is cumbersome because I cannot use boolean operators but have to build boolean logic with a bunch of Yes/No-Conditions.

Sporadic location hick-ups in a complex flow are difficult to debug when 2 runs of the flow make the log overflow.

I'm still looking for a really good way to make my phone location aware. With Automagic I reached about 80% but the location hick-ups prevent me from getting total satisfaction.

Michael

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Minimum precision filter for Location trigger

Post by mcyber » 26 Sep 2014 17:34

In the recent past, I also had a problem similar to your, and I came to the conclusion that Automagic itself were not able to meet 100% my requirement (nor it is, since now).

I have solved completely my problem, and in a very elegant way, (the elegance is not related to my programming skill but to the "economicity" of the solution) by using Autolocation plugin.
It gives the ability to preset all the locations you need and get them by name at runtime (up to 100, as I remember). You can define all the geofences outside of Automagic (what I did), while AM service is running or stopped (and the newly defined geofence is immediately available). You can even add/modify them at runtime, by passing a new geofence name and its parameters or editing an existing one using Automagic Plugin action (by invoking Autolocation Manage - not tried yet, but I've no doubts it works). Along with geofences name you can get other informations such as status (inside/outside), radius (precision), altitude, time. All these are stored into local variables that you can later manipulate to suit your needs. In short, what you can do using Automagic location instructions, with multiple triggers and/or multiple conditions, can easily be done with one single trigger and one single condition or script, with the help of Autolocation. Moreover, you can format some geofence names with some token chars and filter them, so that they can be selected/ignored in a specific trigger, action or condition. Possiblities are really endless and very manageable.
You can try the free version of Autolocation, before buying and see if it fits your needs.

So, Autolocation does the dirty job, and Automagic acts as the glue.

asimov62
Posts: 26
Joined: 10 Jan 2014 11:07

Re: Minimum precision filter for Location trigger

Post by asimov62 » 26 Sep 2014 18:17

Hello, I state that it is not a programmer, and I apologize for my English .... you can also an example of a flow which uses Autolocation? Above all, I can not understand how do you use it on AM. I would be interested to use it to enable and disable the wi fi when I am away from home (usually I locate my phone with the cell phone), but as you know if you do not use the gps is very inaccurate.

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Minimum precision filter for Location trigger

Post by mcyber » 26 Sep 2014 19:32

asimov62 wrote:Hello, I state that it is not a programmer, and I apologize for my English .... you can also an example of a flow which uses Autolocation? Above all, I can not understand how do you use it on AM. I would be interested to use it to enable and disable the wi fi when I am away from home (usually I locate my phone with the cell phone), but as you know if you do not use the gps is very inaccurate.
With only two boxes (a trigger and an action with a bunch of code) I get the job done.
This flow instatiates 2 global variables I use elsewhere to do anything location related (for my needs).
To get it work you should have Autolocation installed and at least a location defined (a very intuitive task in Autolocation).
The two global variables work in conjunction to provide an hysteresis: the same location is defined twice with different radius. A narrow one and a wider (coarse location). The name of the coarse location is the same of the narrow with a "@" appended. So a position is considered inside a location if both the narrow and the coarse variable contain the same name and outside if both are empty.

Here's the flow (requires Autolocation installed).

Surprisingly simple. Isn't it?

http://automagic4android.com/flow.php?i ... 207f1ea96a

asimov62
Posts: 26
Joined: 10 Jan 2014 11:07

Re: Minimum precision filter for Location trigger

Post by asimov62 » 26 Sep 2014 20:24

Ingenious !!! So when your active flow with a periodic time of about ten minutes, I can detect the exact position (in the meantime I have set my position Autolocation), I send you a screenshot modified for my needs of your flow, tomorrow morning I'll try if it works; last thing, if I keep the wifi off Autolocation works just as well? I have some doubts about it.
Screenshot_2014-09-26-22-20-30.png
Screenshot_2014-09-26-22-20-30.png (53.94 KiB) Viewed 21812 times

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Minimum precision filter for Location trigger

Post by mcyber » 26 Sep 2014 20:45

asimov62 wrote:Ingenious !!! So when your active flow with a periodic time of about ten minutes, I can detect the exact position (in the meantime I have set my position Autolocation), I send you a screenshot modified for my needs of your flow, tomorrow morning I'll try if it works; last thing, if I keep the wifi off Autolocation works just as well? I have some doubts about it.
Screenshot_2014-09-26-22-20-30.png
Please remove Periodic Timer otherwise flow won't work properly: when periodic timer fires local variables ARE NOT instatiates. They are instantiated ONLY if the flow is triggered by Autolocation plugin. Furthermore you don't need it at all. All you need is done automatically in background, normally at a higher frequency than 10 min.
If you run android 4.3 or above, I suggest to turn option "WIFI always scan" to ON (you find it in wifi advanced settins). With this option enabled your phone is aware of nearby WiFi spots even when wifi is OFF. It uses very little energy and provides a very good location precision if there's a wifi nearby.
The flow I published DOESN'T supply you the position but tells you if you are inside or not with respect to a location with a predefined accuracy.
Anyway, Autolocation embeds also that feature. In AL site there are many use cases described.
EDIT: I've looked at your modifications. Your flow doesn't work as you suppose. If you are patient I'll post a working one in a few minutes.

mcyber
Posts: 37
Joined: 08 Nov 2013 14:21

Re: Minimum precision filter for Location trigger

Post by mcyber » 26 Sep 2014 21:11

The flow for your problem. This requires two geofences defined with the same center.
One of them must have the @ char appended at the end of the same nome as the first.

example:
location - 10 Downing street London - radius = 100
location@ - 10 Downing street London - radius = 200

(There are other more reliable ways to properly activate wifi when a nearby known access points is detected.)

http://automagic4android.com/flow.php?i ... c3f4cd20b4

Locked