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

tasker convert location

alackman

Android Enthusiast
Aug 24, 2010
334
38
london
hi, ive searched but cannot find any understandable answers to this.

I want to be able to convert the %LOC variable result into an actual nearest town,city or even area name. Is this possible? I want to be able to fire off an autotext when driving that responds with this informaion as opposed to a load of numbers.

any one help?
 
hi, ive searched but cannot find any understandable answers to this.

I want to be able to convert the %LOC variable result into an actual nearest town,city or even area name. Is this possible? I want to be able to fire off an autotext when driving that responds with this informaion as opposed to a load of numbers.

any one help?

I wrote this one a while back but this is the only documented version I have: the Tasker groups thread

Note that this task depends on having an updated network location (%LOCN), this is a lower power draw than GPS Location (%LOC), but you should be able to switch %LOCN for %LOC without issues if you wish.
You can do a 'Location Get' with Tasker first to make sure your location is up to date.

Note also that the newest Tasker versions have better variable cleanups, so you may want to consider copying out %HTTPD to a user variable to make cleanup easier.

Hope this helps.
 
  • Like
Reactions: alackman
Upvote 0
I wrote this one a while back but this is the only documented version I have: the Tasker groups thread

Note that this task depends on having an updated network location (%LOCN), this is a lower power draw than GPS Location (%LOC), but you should be able to switch %LOCN for %LOC without issues if you wish.
You can do a 'Location Get' with Tasker first to make sure your location is up to date.

Note also that the newest Tasker versions have better variable cleanups, so you may want to consider copying out %HTTPD to a user variable to make cleanup easier.

Hope this helps.

Hi codemonkey,

Thank you for this. However, it is way over my head. I've started copying it down, when I get some more time/patience, I will complete it and test. The talk of variable splits and cleanups is what loses me I'm afraid. None of my tasks have more than 8 stages in, so I'm a little daunted by all of this. My problem is I want to understand what each stage means...and I don't! I was hoping it would be easier than this lol. Lots to learn.....again.
 
Upvote 0
Cleanup = variable clear.

When you've finished using a variable that you have created (ie not a system variable) it's good practice to do a variable clear to remove it from memory.

Splits are explained quite well in the user guide, but basically they are a way of breaking a chunk of data contained in one variable into two or more bits based on its contents.

If you can get to grips with the task, then it's pretty easy to supply the extracted postcode back to another Google API and get the current / future weather forecast for the area.
 
Upvote 0
Cleanup = variable clear.

When you've finished using a variable that you have created (ie not a system variable) it's good practice to do a variable clear to remove it from memory.

Splits are explained quite well in the user guide, but basically they are a way of breaking a chunk of data contained in one variable into two or more bits based on its contents.

If you can get to grips with the task, then it's pretty easy to supply the extracted postcode back to another Google API and get the current / future weather forecast for the area.

I get the need for clean up. Also the splits....I just don't understand all the splits in your profile. Maybe it will all make sense once I try it.I'll get back to you on that one. :) I'm not so fussed about the postcode, I just want to be able to text rough location area. I guys I need to run whole profile to be able to understand what I can take out.
 
Upvote 0
Wow, I'm struggling. I can't find the bit in the user guide describing splits and I just can't understand how to define them. How do I know what to put after the % variable for example? (httpd211 etc)

I understand why splits work just not how.

Could you point me in the right direction for the user guide description?

Also any other advice, if you have time, on how I can use the splits etc to collect location data, using gps/google maps so when I'm driving....and plugged in to power my auto response text will add in my location.

I'm sorry, I just can't get my head around your profile enough to work it out myself.
:thinking:

I've copied it exactly..I think. And when I add a pop up to tell me what % LOCNAME should be....I just get % HTTPD11221? Any ideas?
 
Upvote 0
Wow, I'm struggling. I can't find the bit in the user guide describing splits and I just can't understand how to define them. How do I know what to put after the % variable for example? (httpd211 etc)

I understand why splits work just not how.

Could you point me in the right direction for the user guide description?
Splits are explained quite well here

Also any other advice, if you have time, on how I can use the splits etc to collect location data, using gps/google maps so when I'm driving....and plugged in to power my auto response text will add in my location.

I'm sorry, I just can't get my head around your profile enough to work it out myself.
:thinking:

I've copied it exactly..I think. And when I add a pop up to tell me what % LOCNAME should be....I just get % HTTPD11221? Any ideas?

Are you doing a GET first to obtain the location? a variable rerturns its own name when it has no value.

I would start by building a very basic task first to get used to how this all works,
eg:

1. Misc Action: Get Location (Net)
2. HTTP GET (per my first task link)
3. Alert Action: Popup %HTTPD

Test.
The popup should contain the returned data from the GET; this is what we want to split.

As far as knowing what to split, it is trial and error I'm afraid. I built that task over a weekend, using various posts on the tasker google group and the Google API documentation (and several file editing utilities on my old macbook).

When you split a variable it divides into as may sub variables as required (eg %TEST divides into %TEST1 %TEST2 etc as required by the splitter).

As far as the contexts you need I would suggest:

1. State - Power
2. Event - Phone - Received Text
3. <Some other trigger> - bluetooth connected (if you have a car kit / headset you use?)

Alternatively I've seen some posts on the tasker group about detecting movement, but not tried that route myself.
You can then trigger the task based on these contexts; I'd consider setting up some way of ensuring that you aren't checking for location more than you need to (eg if you get 5 texts in 2 minutes you probably don't want to check your location 5 times) - storing the time you last retrieved the location and checking it at the start of the location retrieval woud do it.

This is quite an advanced task if you are just starting out with Tasker so don't be put off by it; start small and build on what you have. It took me about 2 rewrites to be happy with my tasker setup, and I have slimmed down the number of tasks that I was running at one point..
 
  • Like
Reactions: alackman
Upvote 0
I undestand the context parts, ive got my head around most of tasker and now am trting to sort ths splits. I've got about 15 profiles running well without any splits so far. Maybe ill play with splitting something simpler like a name into just 1st name etc. the link you sent has helped clarify somewhat, thank you.

Re this task, I was running the get first. So no idea why it was just bringing up the variable split name. I think to understand this task I need to clarify how you know what to write in the stage that pulls ths data from google? I understand it is this that gets split. But when you just do the get location, you end up with a latitude, longitude number, which would be pointless splitting right? So how do I know how to get the information like town or county etc? Once I have this figured out, I guess I will be able to apply the trial and write to split the variable to get the info I want.

I already have a profile that fires off when I get a text from certain people and when I'm driving (connected to bluetooth car kit). It send a text reply giving my speed and saying I'll respond later. This is where I want to add the task to also say where I am.

So yes, I'll start small. Where does the http get server line come from?
 
Upvote 0
I undestand the context parts, ive got my head around most of tasker and now am trting to sort ths splits. I've got about 15 profiles running well without any splits so far. Maybe ill play with splitting something simpler like a name into just 1st name etc. the link you sent has helped clarify somewhat, thank you.

Re this task, I was running the get first. So no idea why it was just bringing up the variable split name. I think to understand this task I need to clarify how you know what to write in the stage that pulls ths data from google? I understand it is this that gets split. But when you just do the get location, you end up with a latitude, longitude number, which would be pointless splitting right? So how do I know how to get the information like town or county etc? Once I have this figured out, I guess I will be able to apply the trial and write to split the variable to get the info I want.

I already have a profile that fires off when I get a text from certain people and when I'm driving (connected to bluetooth car kit). It send a text reply giving my speed and saying I'll respond later. This is where I want to add the task to also say where I am.

So yes, I'll start small. Where does the http get server line come from?

The GET action:

HTTP GET: Port: maps.google.com/maps/api/geocode/json?latlng=%LOCN&sensor=false Timeout: 10 Mime Type: text/xml

should (if successful) fill the %HTTPD system variable with a response from Google in xml format as documented here
 
  • Like
Reactions: alackman
Upvote 0
hi, ive searched but cannot find any understandable answers to this.

I want to be able to convert the %LOC variable result into an actual nearest town,city or even area name. Is this possible? I want to be able to fire off an autotext when driving that responds with this informaion as opposed to a load of numbers.

any one help?

Ok, so uh, I know this post is old, but, did you ever get this all figured out? I am now looking to do the same thing.
 
Upvote 0
Ok, so uh, I know this post is old, but, did you ever get this all figured out? I am now looking to do the same thing.

I wouldn't say completely figured out but I have got a couple of working profiles that check location and then update % loc variable to be able to add info into auto text etc. it used the httpget and so isn't 100% all the time. (sometimes puts more general area than town, but mostly works. Ill try and write up what I have unless anyone knows of a way to export the profile onto here.
 
Upvote 0
Ok so here goes with what I have as a task that checks for location and sets variable to actual location. Its not perfect as sometimes it finds correct town and sometimes just puts county (I'm in uk, im assuming this makes a difference). If anyone has suggestions to improve although I must admit I've not really played and compared gps with net location.
This is a task which can be run in a profile with perform task *name. If any one wants me to email it to them rather than typing it out, I should be able to do this. Let me know how you get on with it. :)

1.get location
Source net
2 HTTP Get
Server: port maps.googleapis.com/maps/apis/geocode/json?latlng=%LOCN&sensor=false
3. Goto
Type action number
Number 16
If HTTPD = -1
4.variable set
Name %LIN
To 16
5. Read line
File sync
Line %LIN
To var %HTTPD1
6. variable split
Name %HTTPD1
Splitter "
7. Variable set
Name %LOCLONG
To %HTTPD14
8.variable set
Name %LIN
To 17
9. Read line
File sync
Line %LIN
To var %HTTPD1
10.variable split
Name HTTPD1
splitter "
11.if
%HTTPD14 ~ * *
12. Variable split
Name %HTTPD14
13. Variable set
Name %HTTPD14
To %HTTPD141+%HTTPD142
14. End if
15 variable set
Name %LOCSHRT
TO %HTTPD14
16. Variable clear
Name % HTTPD*
 
  • Like
Reactions: GarrMatey
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