• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Tasker save gps location

Caliber

Lurker
Aug 3, 2010
2
0
Just got my DX in the mail today and I've been playing with it ever since! (Coming from LG Dare)

I've been messing with tasker and have an idea but am not sure how to implement it so I thought Id post and see if anyone had any ideas.
I have a pioneer gps unit in my car with hands free bluetooth. My idea is to have tasker save the gps location of my phone when it disconnects from my cars bluetooth and then turn off bluetooth. Then, I can have tasker turn bluetooth back on when I enter that saved location.

I know this may be asking a lot from tasker but what does everyone think?
 
Without seeing exactly what you're doing in Tasker I can't say for sure, but my guess is that you're not getting a current GPS fix before saving the location. Here's what I came up with a while back:

Profile: GetGPSfix
Context: Location [GPS: On] <actual location doesn't matter>
Enter Task:
Stop


After creating the above profile, disable it.


Profile: Car Parked
Context: Bluetooth Connected
Exit Task:
GPS [Set: On]
Profile Status [Name: GetGPSfix] [Set: On]
Wait 30 seconds
Profile Status [Name: GetGPSfix] [Set: Off]
Variable Set [Name: %CARLOC] [Value: %LOC]
GPS [Set: Off]


Tasker doesn't (yet) include the ability to get a current GPS fix before reading the %LOC variable. To get around this we use a dummy profile called GetGPSfix. Enabling a GPS-based location profile causes Tasker to get a current fix. Waiting 30 seconds give the GPS time to determine your location.

The stumbling block with regard to your original post is that you can't user a variable to specify a location for a Location context.
 
Upvote 0
One question, withou GPS, how could you know you've entered that position?

You wouldn't. At least not with enough accuracy to make it usable.

The originally stated purpose isn't doable because Tasker doesn't allow you to specify a location with a variable. I think it's been on the todo list for a while, but it's not available yet.

Even if it was technically possible, (I think) it would be more battery efficient to just leave bluetooth on instead of leaving GPS on in order to know when to turn bluetooth back on.

It would be possible to implement some sort of Bluetooth Near function by turning bluetooth on periodically and seeing if it connected, and if not, turning it off again. But this would require the device to wake up for each check, and could possibly be more of a battery drain than leaving bluetooth on.
 
Upvote 0
I have created the exact profile but it will never get a fix when I enable it. I have selected both Net and GPS, just GPS, and just NET but they will never get a fix when the profile is enabled.

I have the same profile I'm using for finding the location of the phone via SMS. I've adjusted the wait time to 1 minute, which seems to work when the device is awake. However, I've discovered (with some help) that enabling the GetGPSfix profile will not force a GPS fix while the device is asleep. In this case, you have to wait until the Display Off timings under Preferences allow for the location fix to occur.

A way that seems to be working, making sure you get a current fix, is to use these profiles:

Profile: GetGPSfix
Context: Location [GPS: On] <actual location doesn't matter>
Enter Task:
Stop


Profile: WaitForGPSfix
Context: Variable Set %LOCTMS
Task:
Variable Set [Name: %CARLOC] [Value: %LOC]
Profile Status [Name: GetGPSfix] [Set: Off]
Profile Status [Name: WaitForGPSfix] [Set: Off]
GPS [Set: Off]


Profile: Car Parked
Context: Bluetooth Connected
Exit Task:
GPS [Set: On]
Profile Status [Name: WaitForGPSfix] [Set: On]
Profile Status [Name: GetGPSfix] [Set: On]

This waits for the time of the last GPS fix to be updated. I believe when Tasker reaches the GPS Timeout period it will return a network-based location value and update the time of last fix.
 
Upvote 0
Can you explain what %LOCTMS Context does? I know the varable is the time from last fix but not sure why it would wait until there is a current fix? Is the Variable Set [Name: %CARLOC] [Value: %LOC] needed?

The %LOCTMS variable is the time of the last fix, as you said. The WaitForGPSfix profile waits for that time to be updated, indicating that a fix has just been obtained, and then records the current location in %CARLOC so that future fixes don't cause that value to get lost.

With the default settings in Tasker, if your device has been asleep for a while, the position stored in %LOC could be up to 10 minutes old if you have a GPS-based profile enabled, or even older if no profiles are using GPS. When you wake up the device, it will immediately try to get a fix if any GPS-based profiles are enabled, so the wait normally won't be long, but if you just grab the current value of %LOC without making sure the information is recent, your location could be way off.
 
Upvote 0
That sounds like it would work fine with the SMS location for finding a lost phone but it sounds like if you were using it for a Car Location that you could be a mile away before a fix was given. It would be nice if tasker could somehow force a GPS fix.

If you're triggering this with a widget or while the device is otherwise awake, it should only take a minute or so.

A forced GPS fix is on the to do list already.
 
Upvote 0
Hi Uncle Mike,
I'm trying to do something similar using your code to let my phone know whether I'm driving or not. The idea was when I leave home (my wifi disconnects) my gps turns on, it uses %loc data so if spied is greater than e.g. 4m/s then this is driving (will then be used to change call settings etc)
The problem is updating the %loc data - I've used what you've done but its not working and I have a few questions...
Essentially, in what order does Tasker manage nested profiles? Your "Parked Car" send to run "Wait..." before it runs "Get..." "Wait..." then seems to set carloc to %loc BEFORE running "Get...", and then closes "Get..." which I didn't think had been started yet...
Please help! :-(
And thank you, I'm already much closer thanks to you!
 
Upvote 0
Hi Uncle Mike,
I'm trying to do something similar using your code to let my phone know whether I'm driving or not. The idea was when I leave home (my wifi disconnects) my gps turns on, it uses %loc data so if spied is greater than e.g. 4m/s then this is driving (will then be used to change call settings etc)
The problem is updating the %loc data - I've used what you've done but its not working and I have a few questions...
Essentially, in what order does Tasker manage nested profiles? Your "Parked Car" send to run "Wait..." before it runs "Get..." "Wait..." then seems to set carloc to %loc BEFORE running "Get...", and then closes "Get..." which I didn't think had been started yet...
Please help! :-(
And thank you, I'm already much closer thanks to you!

I had to go back and see what I wrote, which was about 6 weeks ago. Since that time, Tasker has the added ability to force a current GPS fix, so I would probably re-write the whole thing. I think it's best to start from scratch at this point. What iis it you're trying to do?
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones