How can I get tasker to display my current street address

2,272 views
Skip to first unread message

Eric Mixson

unread,
Jul 13, 2014, 9:27:12 PM7/13/14
to tas...@googlegroups.com
I would like to trigger a log of my current location using the street address and not the coordinates.  

Thanks in advance.

Jeremy Harris

unread,
Jul 13, 2014, 9:41:27 PM7/13/14
to tas...@googlegroups.com
Playing around with a wiki project that Brandon made, that i know does this...I think you can convert %LOL using Google's API in a HTTP Get action and this path:

/maps/api/geocode/xml?latlng=%loc&sensor=false

Jeremy Harris

unread,
Jul 13, 2014, 9:43:01 PM7/13/14
to tas...@googlegroups.com
Edit: %LOC

Hopefully it points you in the right direction.

Brandon Horwath

unread,
Jul 13, 2014, 10:31:58 PM7/13/14
to tas...@googlegroups.com
This isn't exactly what's used, but it'll get you there:

A1: Get Location [ Source:GPS Timeout (Seconds):120 Continue Task Immediately:Off Keep Tracking:Off ]
A2: Variable Set [ Name:%locage To:%TIMES - %LOCTMS Do Maths:On Append:Off ]
A3: Goto [ Type:Action Number Number:1 Label: ] If [ %locage > 59 ]
A4: Variable Set [ Name:%loc To:%LOC Do Maths:Off Append:Off ]
A5: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%loc&sensor=false Attributes: Cookies: Timeout:15 Mime Type: Output File: Trust Any Certificate:Off ]
A6: Variable Set [ Name:%httpd To:%HTTPD Do Maths:Off Append:Off ]
A7: Variable Search Replace [ Variable:%httpd Search:(?<=address>).+(?=</format) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%result Replace Matches:Off Replace With: ]
A8: Flash [ Text:%result1 Long:Off ]

Hope this helps.

Amir S.

unread,
Jul 14, 2014, 8:34:51 PM7/14/14
to tas...@googlegroups.com
Hey Brandon Thanks!
How can i get the text between the <formatted_address> tags to a value using the variable search replace action?


This is the beginning of the %HTTPD value:

<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
<status>OK</status>
<result>
<type>street_address</type>
<formatted_address>1234 Las Vegas Ave, Las Vegas, NV 89123, USA</formatted_address>

Bob Hansen

unread,
Jul 14, 2014, 8:47:47 PM7/14/14
to tas...@googlegroups.com
Use the variable search as shown below.

A1: Variable Set [ Name:%text To:<?xml version="1.0" encoding="UTF-8"?>
<GeocodeResponse>
 <status>OK</status>
 <result>
  <type>street_address</type>
  <formatted_address>1234 Las Vegas Ave, Las Vegas, NV 89123, USA</formatted_address> Do Maths:Off Append:Off ]
        A2: Variable Search Replace [ Variable:%text Search:(?<=<formatted_address>).+(?=</formatted_address>) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%result Replace Matches:Off Replace With: ]
        A3: Flash [ Text:%result(1) Long:Off ]

Amir Salach

unread,
Jul 14, 2014, 9:06:52 PM7/14/14
to tas...@googlegroups.com

Ohhhh the value is am ARRAY! I kept using %ADDRESS instead of %ADDRESS1....sheesh.

But thanks your regex grabs the text inside the tags while the regex i used kept the tags.

Thanks Bob!

Here is the simplest version:

Location To Address (769)
A1: Variable Clear [ Name:%LOC Pattern Matching:Off ]
A2: Get Location [ Source:Any Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:Off ]
A3: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %LOC Is Set ]
A4: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%LOC&sensor=false Attributes: Cookies: Timeout:10 Mime Type: Output File: Trust Any Certificate:Off ]
A5: Variable Search Replace [ Variable:%HTTPD Search:(?<=<formatted_address>).+(?=</formatted_address>) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%ADDRESS Replace Matches:Off Replace With: ]
A6: Flash [ Text:%ADDRESS1 Long:Off ]

--
You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/_SPCn3hztRE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/tasker.
For more options, visit https://groups.google.com/d/optout.

Brandon Horwath

unread,
Jul 14, 2014, 10:07:23 PM7/14/14
to tas...@googlegroups.com
A1: Variable Clear [ Name:%LOC Pattern Matching:Off ]

Just get rid off that. Tasker ignores it anyway as an error.

No offense, but the only way to guarantee a 'current' location (not based on previously obtained %LOC value) is with the method I listed using a loop.

Amir Salach

unread,
Jul 16, 2014, 3:54:36 AM7/16/14
to tas...@googlegroups.com

I did it that way because i see it as a repetitive task you'll do again and again, and on top of that from testing and personal knowledge of people's behavior, they have their GPS on anyways PLUS this task uses network location too which is by DEFAULT enabled in every android device and under many tests in phone it already has current location info from background apps or finds it in seconds.

That's my logic but i understand what you mean in the programming sense ;-)

Rich D

unread,
Jul 16, 2014, 9:30:36 AM7/16/14
to Tasker Google Groups Post


> I did it that way because i see it as a repetitive task you'll do again and again,

Not sure what that has to do with brandons recomdation?

and on top of that from testing and personal knowledge of people's behavior, they have their GPS on anyways PLUS this task uses network location too which is by DEFAULT enabled in every android device and under many tests in phone it already has current location info from background apps or finds it in seconds.
>
> That's my logic

I think Brandon was trying to point out that your logic is not working as you expect.

A1: Variable Clear [ Name:%LOC Pattern Matching:Off ]

This will not clear %LOC. You can not edit a system variable.


A2: Get Location [ Source:Any Timeout (Seconds):10 Continue Task Immediately:On Keep Tracking:Off ]
A3: Wait Until [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ] If [ %LOC Is Set ]

This means %LOC will always be set and A3 will never wait and you since you have 'continue task immediately' checked in the get location then you will can end up with the previous %LOC value. 

Although if I am not mistaken Brandons method will force the task to wait until the gps has a new fix which is the same as if you did not have 'continue task immediately' checked.  (I think)..

I would recommend the same loop as Brandon recommended  except put a 1 sec wait in it then only let it loop as long as you want and if no fix in x loops then use %LOCN instead... 

Brandon Horwath

unread,
Jul 16, 2014, 12:21:06 PM7/16/14
to tas...@googlegroups.com
Spot on Rich.

I also suggest looking at %LOCACC. Since you're using %LOCN, location accuracy would be good to know.

Fyi, I realize about GPS... the task actually used accounts for it being off, queried interval loops timeout, force action stops, disabled data connection, etc. This is just the bare basics to get an address in the above example.

But, yes. Rich mentioned exactly why I made the suggestion. However, I see what you mean (off the top) about it continually looping if no GPS is determined. The actual task accounts for such a possibility though.

Here's the actual task used that initiates a address check. You'll notice that GPS being off is taken into account, the qquery to enable GPS, reverting settings, highlighting accuracy, indicating errors, endless loop prevention, ensured forced timeout, etc.

Oh, and it makes a little GPS icon flicker on/off in the scene so you know it's busy/working ;-) (way cooler than a standard one second wait!)

Obtain Current Address (52)
A1: Stop [ With Error:Off Task:Calendar Manual Timeout Task ]
A2: Variable Set [ Name:%gps To:off Do Maths:Off Append:Off ] If [ %GPS ~ off ]
A3: GPS [ Set:On Continue Task After Error:On ] If [ %GPS ~ off ]
<GPS Test>
A4: If [ %GPS ~ off ]
A5: Variable Add [ Name:%gps_timeout Value:1 Wrap Around:0 ]
A6: Wait [ MS:0 Seconds:5 Minutes:0 Hours:0 Days:0 ] If [ %GPS ~ off ]
A7: Goto [ Type:Action Label Number:1 Label:GPS Test ] If [ %gps_timeout < 6 & %GPS ~ off ]
A8: End If
A9: Test Scene [ Name:Calendar Entry Test:Status Store Result In:%scene ]
A10: Show Scene [ Name:Calendar Entry Display As:Activity, Full Window, No Bar Horizontal Position:100 Vertical Position:100 Animation:System Show Exit Button:Off Continue Task Immediately:On ] If [ %scene !~ visible ]
A11: If [ %GPS ~ on ]
A12: Variable Set [ Name:%times To:%TIMES Do Maths:Off Append:Off ]
A13: Variable Clear [ Name:%Cal_loc Pattern Matching:Off ]
A14: Get Location [ Source:GPS Timeout (Seconds):120 Continue Task Immediately:On Keep Tracking:Off Continue Task After Error:On ]
<Get Location>
A15: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hl_device_access_location_searching ]
A16: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A17: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_searching ]
A18: Wait [ MS:500 Seconds:0 Minutes:0 Hours:0 Days:0 ]
A19: Variable Set [ Name:%locage To:%TIMES - %LOCTMS Do Maths:On Append:Off ]
A20: Goto [ Type:Action Label Number:1 Label:End ] If [ %times + 120 < %TIMES ]
A21: Goto [ Type:Action Label Number:1 Label:Get Location ] If [ %locage > 120 ]
A22: Flash [ Text:Location found, retrieving data... Long:Off ] If [ %LOC Is Set & %locage < 121 ]
A23: Stop Location [ Source:GPS ]
A24: Variable Set [ Name:%loc To:%LOC Do Maths:Off Append:Off ] If [ %LOC Is Set ]
A25: HTTP Get [ Server:Port:maps.googleapis.com Path:/maps/api/geocode/xml?latlng=%loc&sensor=false Attributes: Cookies: Timeout:15 Mime Type: Output File: Trust Any Certificate:Off Continue Task After Error:On ] If [ %loc Is Set ]
A26: Variable Set [ Name:%httpd To:%HTTPD Do Maths:Off Append:Off ] If [ %HTTPD Is Set ]
A27: Variable Search Replace [ Variable:%httpd Search:(?<=address>).+(?=</format) Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In:%result Replace Matches:Off Replace With: ]
A28: Variable Set [ Name:%Cal_loc To:%result1 Do Maths:Off Append:Off ] If [ %result1 Is Set ]
A29: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:%result1 ] If [ %result1 Is Set ]
A30: Element Visibility [ Scene Name:Calendar Entry Element Match:Location Accuracy Text Set:True Animation Time (MS):400 ] If [ %result1 Is Set ]
A31: Variable Set [ Name:%Cal_loc To:Error occurred! Do Maths:Off Append:Off ] If [ %result1 ! Set ]
A32: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:Error occurred! ] If [ %result1 ! Set ]
A33: End If
A34: Variable Set [ Name:%Cal_loc To:Please enable GPS Do Maths:Off Append:Off ] If [ %GPS ~ off ]
A35: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:Please enable GPS ] If [ %GPS ~ off ]
A36: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_alerts_and_states_warning ] If [ %GPS ~ off ]
A37: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_found ] If [ %Cal_loc !~ Error occurred! & %GPS !~ off ]
A38: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_off ] If [ %Cal_loc ~ Error occurred! ]
A39: GPS [ Set:Off ] If [ %gps ~ off ]
A40: Perform Task [ Name:Calendar Manual Timeout Task Stop:Off Priority:%priority - 1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] If [ %Share_event !~ true ]
A41: Stop [ With Error:Off Task:Obtain Current Address ]
<End>
A42: Anchor
A43: Element Text [ Scene Name:Calendar Entry Element:Calendar Location Position:Replace Existing Text:An error occurred! ]
A44: Element Image [ Scene Name:Calendar Entry Element:GPS Address Button Image:hd_device_access_location_off ]
A45: Stop Location [ Source:GPS ]
A46: GPS [ Set:Off ] If [ %gps ~ off ]
A47: Perform Task [ Name:Calendar Manual Timeout Task Stop:Off Priority:%priority - 1 Parameter 1 (%par1): Parameter 2 (%par2): Return Value Variable: ] If [ %Share_event !~ true ]
A48: Stop [ With Error:Off Task:Obtain Current Address ]

Soli Engineer

unread,
Feb 4, 2016, 2:00:56 AM2/4/16
to Tasker
I would be grateful if the XML file is made available.
Thank you

Rich D

unread,
Feb 4, 2016, 6:55:23 AM2/4/16
to Tasker Google Groups Post


> I would be grateful if the XML file is made available.
> Thank you

Have you tried searching this group?  I am sure I have seen this posted several times.

Lucas Rohr

unread,
Apr 1, 2017, 8:37:53 AM4/1/17
to Tasker
I know I'm years late, but just let me say that I love you, whoever you are. This drove me insane.

Brandon Horwath

unread,
Apr 6, 2017, 9:38:04 AM4/6/17
to tas...@googlegroups.com
Glad I could help!
> --
> You received this message because you are subscribed to a topic in the Google Groups "Tasker" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/tasker/_SPCn3hztRE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to tasker+un...@googlegroups.com.
> Visit this group at https://groups.google.com/group/tasker.

Jeremy Harris

unread,
Apr 6, 2017, 10:56:37 PM4/6/17
to tas...@googlegroups.com
Woah, good to see you around!  Hope you're well!  PM me sometime!

Duck Redbeard

unread,
Jun 28, 2017, 9:28:43 PM6/28/17
to Tasker
I tried copying Brandons task description above, saving it as getaddress.tsk.xml, then importing it into tasker. Kept getting a bad data format error. How do I get this into tasker without stepping through each action?

Dale Smith

unread,
Feb 17, 2018, 6:24:21 PM2/17/18
to Tasker
I couldn't get the search replace action as written to work. Try using the following in the search: (?<=address>).+(?=<)  

Rich D

unread,
Feb 17, 2018, 8:52:23 PM2/17/18
to Tasker Google Groups Post


I couldn't get the search replace action as written to work. Try using the following in the search: (?<=address>).+(?=<)  


Regex always takes me a while to get it correct, so I will usually use variable split on the easy stuff.  Here is what I have been using for years.

my location task (423)
A1: HTTP Get [ Server:Port:maps.google.com/maps/api/geocode/json?latlng=%newloc&sensor=false Path: Attributes: Cookies: User Agent: Timeout:120 Mime Type:text/xml Output File:testfile.txt Trust Any Certificate:Off Continue Task After Error:On ] 
A2: Variable Set [ Name:%address To:%HTTPD Recurse Variables:Off Do Maths:Off Append:Off ] 
A3: Variable Split [ Name:%address Splitter:"short_name" Delete Base:Off ] 
A4: Variable Split [ Name:%address3 Splitter:" Delete Base:Off ] If [ %address3 Set ]


The results are in %address32.   Have a look in the %HTTPD.  There is a lot of info in there and you might want the long name instead of the short name as this task gets. 

Dale Smith

unread,
Feb 18, 2018, 11:26:51 AM2/18/18
to Tasker
Good help Rich, as always but I still like the regex approach. Have a look at this web site. I helps you build a regex and lets you test it on your target text. https://regex101.com/

Duck Redbeard

unread,
Feb 18, 2018, 12:48:38 PM2/18/18
to Tasker
I tried copying these tasks to a text editor and saving as .tsk.xml files. When I try to import I get an error bad data format message. How do I convert text to a task.

Rich D

unread,
Feb 18, 2018, 1:25:14 PM2/18/18
to Tasker Google Groups Post

Good help Rich, as always but I still like the regex approach.

Ha, I misunderstood your post. I thought you were having trouble with the regex. Oh well now they have 2 separate approaches. I believe the variable split might be more novice friendly if they indeed want to find different parts of the address. 


Have a look at this web site. I helps you build a regex and lets you test it on your target text. https://regex101.com/


Thanks Dale. That is the one I use when I need a regex.. :)




Rich D

unread,
Feb 18, 2018, 1:27:23 PM2/18/18
to Tasker Google Groups Post


I tried copying these tasks to a text editor and saving as .tsk.xml files.  When I try to import I get an error bad data format message.  How do I convert text to a task.

All the tasks posted here are human readable "descriptions" they can not be loaded into tasker.  

What exactly are you looking for?

Duck Redbeard

unread,
Feb 18, 2018, 1:58:07 PM2/18/18
to Tasker
Extracting an address from location data.

Rich D

unread,
Feb 18, 2018, 2:25:43 PM2/18/18
to Tasker Google Groups Post
Here ya go.


my_location_task.tsk.xml

Rich D

unread,
Feb 18, 2018, 2:44:30 PM2/18/18
to Tasker Google Groups Post
@Dale.

I tried your regex and it did not work in this task. 
my location task (983)


A1: Get Location [ Source:GPS Timeout (Seconds):100 Continue Task Immediately:Off Keep Tracking:Off ] 
A2: HTTP Get [ Server:Port:maps.google.com/maps/api/geocode/json?latlng=%LOC&sensor=false Path: Attributes: Cookies: User Agent: Timeout:120 Mime Type:text/xml Output File:testfile.txt Trust Any Certificate:Off Continue Task After Error:On ] 
A3: Variable Set [ Name:%address To:%HTTPD Recurse Variables:Off Do Maths:Off Append:Off ] 
A4: Variable Search Replace [ Variable:%address Search:(?<=address>).+(?=<) Ignore Case:On Multi-Line:On One Match Only:On Store Matches In:%result Replace Matches:Off Replace With: ] 
A5: [X] Variable Split [ Name:%address Splitter:"formatted_address" Delete Base:Off ] 
A6: [X] Variable Split [ Name:%address2 Splitter:" Delete Base:Off ] If [ %address2 Set ]
A7: [X] Flash [ Text:%address22 Long:On ] 
A8: Flash [ Text:%result() Long:On ] 


Duck Redbeard

unread,
Feb 18, 2018, 7:23:47 PM2/18/18
to Tasker
Thanks Rich D. Exactly what I was loooking for.

Dale Smith

unread,
Feb 19, 2018, 9:46:05 PM2/19/18
to Tasker
That surprises me. I just changed it to remove the state, zip code, USA component.
(?<=address>).+(?=, CA)
Don't understand why it doesn't work for you.

Rich D

unread,
Feb 19, 2018, 10:18:22 PM2/19/18
to Tasker Google Groups Post

That surprises me. I just changed it to remove the state, zip code, USA component.
(?<=address>).+(?=, CA)
Don't understand why it doesn't work for you.

Ahh.. My bad. It looks like I am using a different api. 

Rich D

unread,
Feb 20, 2018, 5:27:30 AM2/20/18
to Tasker Google Groups Post
Just tested with Brandon's api and the original regex you posted worked although it gave a lot of extra info like

'my street address'  , USA,'my town', MA, USA,'my town', MA 0'my zip', USA,'nearby town', MA, MA, USA,Franklin County, MA, USA,Springfield, MA, MA, USA,Massachusetts, USA,United States

This one does not seem to work

(?<=address>).+(?=, CA)




Dale Smith

unread,
Feb 20, 2018, 1:18:35 PM2/20/18
to Tasker
Are you in California?

Rich D

unread,
Feb 20, 2018, 4:33:30 PM2/20/18
to Tasker Google Groups Post
Are you in California?

Nope..

Dale Smith

unread,
Feb 21, 2018, 10:38:48 AM2/21/18
to Tasker
Ok, that's it then I'm filtering out my state component. ", CA".
Reply all
Reply to author
Forward
0 new messages