Hi Folks!
I have a question about automagic flows. I would like to disable Bluetooth and enable WiFi, if I stay at the same location more than a few minutes.
If I leave the location, it should be enable Bluetooth and disable WiFi.
Is it possible to save the last location with radius x Meter and compare it with a new one?
The expression (location1 == location2) can't working, but this is for understanding.
Maybe it is better to see the flow:
Staying at the same position -> action
Moderator: Martin
Re: Staying at the same position -> action
You are trying Geofencing but for static location. It is possible to compare location 1 to 2, by saving previous location to gloVar first, example {global_last_position}. Make sure you save it as the type location, it should be location type already if you assign directly from the trigger's variable {location}.
Then you can use expression
somewhere before the end of the flow, add a new script to save current location to the glovar
If you understand the concept already, you can actually combine both of them into the same expression. (no need additional script at the end of the flow)
We compare current location with previous one, save it in {test}. Then save current location to glovar. Finally check the result of the test. In expression, the last executed statement (even inside a if()) must always evaluated to true or false, thus the test should be the last.
But location is very sensitive, move a bit, and you probably have a different coordinate. So it is better to calculate the distance. You can calculate it using distance(). The result is in meters. The expression below check if the distance of current location vs previous location is more than 20 meters.
I think this is not the best way to check for the static location. You have wifi AP nearby, just use wifi connected/disconnected as the trigger, or wifi available as the condition. Since you need timer, probably geofencing concept from the other thread can be used. viewtopic.php?f=6&t=7137
Then you can use expression
Code: Select all
location == global_last_position
Code: Select all
global_last_position = location;
Code: Select all
test = location == global_last_position;
global_last_position = location;
test
But location is very sensitive, move a bit, and you probably have a different coordinate. So it is better to calculate the distance. You can calculate it using distance(). The result is in meters. The expression below check if the distance of current location vs previous location is more than 20 meters.
Code: Select all
dis = distance(location, global_last_position);
global_last_position = location;
dis > 20
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.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
-
- Posts: 2
- Joined: 31 Dec 2017 08:44
Re: Staying at the same position -> action
Thanks for your answer and the correct way to control WiFi and Bluetooth, it works perfect! 
