Skip to content

Instantly share code, notes, and snippets.

@whiteinge
Created January 1, 2013 20:03
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save whiteinge/4429633 to your computer and use it in GitHub Desktop.
Save whiteinge/4429633 to your computer and use it in GitHub Desktop.
A Tasker task for texting a driving time estimate between your current location and home. Expects two variables to be set: HOME: An address, zip code, etc to use as the destination address when querying the Google Maps API. HOMENUM: A phone number to send the text to.
<TaskerData sr="" dvi="1" tv="1.3.3u2m">
<Task sr="task2">
<cdate>1345254133188</cdate>
<edate>1357068354779</edate>
<id>2</id>
<nme>Headed Home</nme>
<pri>10</pri>
<Action sr="act0" ve="3">
<code>902</code>
<Int sr="arg0" val="0"/>
<Int sr="arg1" val="100"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act1" ve="3">
<code>118</code>
<Str sr="arg0" ve="3">maps.googleapis.com</Str>
<Str sr="arg1" ve="3">maps/api/directions/json</Str>
<Str sr="arg2" ve="3">origin=%LOC
destination=%HOME
sensor=false</Str>
<Str sr="arg3" ve="3"/>
<Int sr="arg4" val="10"/>
<Str sr="arg5" ve="3">text/plain</Str>
<Str sr="arg6" ve="3"/>
</Action>
<Action sr="act2" ve="3">
<code>129</code>
<lhs>%HTTPL</lhs>
<op>4</op>
<rhs>0</rhs>
<Str sr="arg0" ve="3">var t = JSON.parse(global('HTTPD'));
var dur = t.routes[0].legs[0].duration.text;
var dist = t.routes[0].legs[0].distance.text;
var msg = "I'm in the car. Headed home.";
if (dist) msg += " I'm " + dist + " away.";
if (dur) msg += " With an estimated " + dur + " driving time (not accounting for traffic).";
var ok = sendSMS(global('HOMENUM'), msg);
flashLong("Sent message: " + msg);</Str>
<Str sr="arg1" ve="3"/>
<Int sr="arg2" val="1"/>
<Int sr="arg3" val="45"/>
</Action>
</Task>
</TaskerData>
@duckredbeard
Copy link

Also note in that thread that I mentioned that I changed line 43 to be "%" before the HOMENUM so it would reference the variable.

@dcdevito
Copy link

I created both test variables accordingly, but it does not work. No errors are returned but nothing happens. Any ideas?

@goldfndr
Copy link

@duckredbeard It isn't necessary to use a % symbol in the global() function, it's optional.

@j0be
Copy link

j0be commented Jul 12, 2021

I'm getting an auth error.
Screenshot_20210712-182421

@micmusic85
Copy link

micmusic85 commented Apr 8, 2022

It's also not working for me. Has anyone managed to get this working again or found an alternative?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment