Tasker save gps location


  1. Caliber

    Caliber New Member

    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?

    Advertisement
  2. UncleMike

    UncleMike Well-Known Member

    If you're thinking of using a GPS Location (as opposed to a Network Location) you'll probably find that just leaving bluetooth on all the time will be more efficient in terms of battery use.

    If you want to try it anyway, I can certainly whip something up.
  3. edhgreatone

    edhgreatone Well-Known Member

    bump for an answer on this I was thinking initally... add state - bluetooth connection and then make a fony task... and then add exit task to bluetooth connection to save gps location... didn't work though..
  4. UncleMike

    UncleMike Well-Known Member

    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.
  5. Brinkley1988

    Brinkley1988 Well-Known Member

    One question, withou GPS, how could you know you've entered that position?
  6. UncleMike

    UncleMike Well-Known Member

    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.
  7. SlimJimE

    SlimJimE Member


    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.
  8. UncleMike

    UncleMike Well-Known Member

    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.
  9. SlimJimE

    SlimJimE Member

    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?
  10. UncleMike

    UncleMike Well-Known Member

    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.
  11. SlimJimE

    SlimJimE Member

    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.
  12. UncleMike

    UncleMike Well-Known Member

    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.
  13. MarkusIscariot

    MarkusIscariot New Member

    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!
  14. MarkusIscariot

    MarkusIscariot New Member

    Oops, "spied" means "speed", "send" means "seems"
    That's the problem with swype ;-)
  15. UncleMike

    UncleMike Well-Known Member

    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?

Share This Page