Different addresses in location

Post your questions and help other users.

Moderator: Martin

Post Reply
jfknyc
Posts: 14
Joined: 23 Mar 2017 14:38

Different addresses in location

Post by jfknyc » 03 Jan 2019 12:14

Hi all,

how can I add more addresses in one condition? or do I hve to create for each address a new condition? For network based location AM searches the networks where I am actually in and add it, correct?

Thanks

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Different addresses in location

Post by Desmanto » 03 Jan 2019 18:03

Yes, you can add them in parallel. So add point A at expression 1, B at 2 and C at 3. Connect from previous element to all these 3 at once (parallel).
If you need a lot of point, probably it is better to store those location coordinate as list, and loop check them using distance(). If the distance is less than certain radius threshold (example 20 meters), then you are inside that location.

Network based location usually use the location provided by the Google Play services. Sometimes it is not 100% accurate, so you have to check first.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

jfknyc
Posts: 14
Joined: 23 Mar 2017 14:38

Re: Different addresses in location

Post by jfknyc » 04 Jan 2019 11:31

Sorry, what does that mean in "Expressio"? Are these the conditions?

What I have done now, is

trigger: periodic timer-each 15m
condition: arrive Home address
true= turn wifi on
false=Cell ID work office - True_turn wifi on

But I want all my known addresses (friends etc) where I can use wifi into one condition..how do I do that with "expression"?

Thanks
Sven

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Different addresses in location

Post by Desmanto » 06 Jan 2019 10:40

Sorry, I mean the condition location, the one you use to check the location.

The trigger can be still the same, periodic timer. After that, put as many condition location as you need to check it. The parallel way is show as in this thread : viewtopic.php?f=5&t=6882 (except, you don't need input dialog).

Each condition location checks for single place with its own radius. Example, you have 3 condition location. All true branches from these will go to turn on wifi, while false do nothing (no connection at all).


Since you are checking for multiple location, I think it is better to use Trigger Location instead. I don't know how the trigger perform at your phone, but usually it is much faster than 15 minutes delay. You can add as many triggers as the location to check. Only one triggered, will execute the action (turn wifi on). Using periodic timer, you will have latency up to the periodic time you use, which is 15 minutes. It is possible at the periodic check, you are not at the location. Just 1 second after that, the phone detect the location properly, but it won't switch on wifi until the next 14 minutes 59 seconds check.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

jfknyc
Posts: 14
Joined: 23 Mar 2017 14:38

Re: Different addresses in location

Post by jfknyc » 07 Jan 2019 10:09

Thanks. I think, I got it..So Trigger Location is better then the peridoc timer. I will add all the addresses as trigger (as this is "or" in the trigger, correct?).

What about turn wifi off when I leave one of these addresses? Then I have to use

Trigger Wifi connected

Leave address as condition and action would be turn wifi off, correct? So here I have to work with true and false and different conditions or is there an easier way like turn wifi on?

It would be easier, if all the addresses can be saved in one condition separated by comma

Thanks
Sven

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Different addresses in location

Post by Desmanto » 07 Jan 2019 17:32

Yes, add as many address as you need in the same flow, all of them as trigger. The logic is OR, one triggered, it will execute the flow.

For exiting, you need AND logic, as you need to check that you are not in any one of the location you put there. But the better trigger for exit is Wifi disconnected and added up some action sleep as buffer. My wifi geofencing flow use 5 minutes as buffer. As you don't want the main action to be executed just because you are roaming around the room and get disconnected temporary.

No need to check for the location again. Because if you are entering any of those location again, the entering flow will be executed and wifi turned on again.


If you really need to check for multiple address at once, just store them in list and loop check the distance. Use Init Variable Location to get you current location as the starting point to count the distance, store in {location}. You can use the variable from the trigger location or condition too, but remember you want your current position. Then copy the list of the coordinate point of your favourite location into the script.

Code: Select all

listloc = newList(
newLocation(1.234567, 98.765432),
newLocation(2.345678, 87.654321),
newLocation(3.456789, 76.543210),
newLocation(4.567890, 65.432109) );

dis = newList();
for(i in listloc)
  addElement(dis, round(distance(i, location)));

min = sort(dis,true,true)[0];
Replace the coordinate in the listloc with yours. The loop will check the distance, round it to the nearest meter and store it at {dis} list. Then we sort the list, so the minimum distance is at the first element, which we query use [0]. {min} now contain the minimum distance from the list of address you have in the list to the current position.

After the script, add condition expression to check the minimum distance tolerance you need. Example, you want 20 meters.

Code: Select all

min  <= 20
Which mean if the minimum distance is less than 20 meters, you are in one the location you have specified, true branch - turn on the wifi. Or vice versa, you can use the false branch for denoting you are not in the location, turn off wifi.

But be careful, newer android version now require you to enable wifi before it can scan the location using network provider. So turning on/off wifi might not be a good idea.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

jfknyc
Posts: 14
Joined: 23 Mar 2017 14:38

Re: Different addresses in location

Post by jfknyc » 08 Jan 2019 07:57

Thanks..I will check it and wills ee, what best will work for me.

Post Reply