Using Tasker to send SMS with ETA info

1,853 views
Skip to first unread message

Duck Redbeard

unread,
Jul 20, 2015, 8:28:38 AM7/20/15
to tas...@googlegroups.com
I stumbled upon a site that has a Tasker task that some may find useful.  It is a task that gets your location, calculates the ETA to a predetermined location, then sends an SMS to a recipient with that ETA info.  I am having difficulty getting it to work.  The website says to set two variables.  One is your destination, which is the %HOME variable.  I set that as my home address and it all seems to work, as it said I was 20 feet away and a travel time of one minute.  I am home, so it is working (as seen in the toast at the end of the task).  

The second variable is the HOMENUM. I set my cell phone as the "HOMENUM" and I am not getting the message.  I do get the toast that has all the info.  On line 43 of the xml, it says "var ok = sendSMS(global('HOMENUM'), msg);" and this is where I substituted my phone number. If I remove the single quote marks inside the parentheses, I get a "com.android.phone has stopped" or something like that. Reinserting the single quote marks fixes that, but I never get the text message.

Anyone got any ideas what I'm doing wrong?

Duck Redbeard

unread,
Jul 20, 2015, 9:48:29 AM7/20/15
to tas...@googlegroups.com
Got it… should be like this for line 43:

var ok = sendSMS(global('%HOMENUM'), msg);

The % was omitted before the HOMENUM

Odysseos

unread,
Jul 20, 2015, 11:08:44 AM7/20/15
to tas...@googlegroups.com
You can use local variables instead of Globals. So your javascript code will be:

sendSMS(homenum, msg); (no need to prefix with var ok =)

If you want to store the sent msg in your SMS app, add true at the end of the code:

sendSMS(homenum, msg, true);

Duck Redbeard

unread,
Jul 21, 2015, 10:48:54 AM7/21/15
to tas...@googlegroups.com
Here is what I have settled on. You need to create two variables. One is for your destination. It shall be %HOME and it should be populated using your destination address without punctuation or abbreviation except for state. The second is for the recipient of your message. It shall be %HOMENUM and it should be a 7 digit phone number without dashes or punctuation. Use your own number to test it a few times before you barrage your mate with messages.

I tested it this morning and it sent a message estimating a 39 minute commute that ended up being 43 minutes. Not bad considering I went through Atlanta GA during rush hour. Pretty accurate for a 30 mile drive in wildly unpredictable traffic. An accuracy like that is good enough!

I am having Tasker/Secure settings enable GPS at the start of the task to ensure location accuracy. GPS is turned off at the end if I am not using it for any other app.




<TaskerData sr="" dvi="1" tv="4.7u3m">
<Task sr="task247">
<cdate>1345254133188</cdate>
<edate>1437488739214</edate>
<id>247</id>
<nme>Headed Home</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>11820</code>
<Bundle sr="arg0">
<Vals sr="val">
<com.intangibleobject.securesettings.plugin.extra.BLURB>GPS Enabled</com.intangibleobject.securesettings.plugin.extra.BLURB>
<com.intangibleobject.securesettings.plugin.extra.BLURB-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.BLURB-type>
<com.intangibleobject.securesettings.plugin.extra.ENABLED>true</com.intangibleobject.securesettings.plugin.extra.ENABLED>
<com.intangibleobject.securesettings.plugin.extra.ENABLED-type>java.lang.Boolean</com.intangibleobject.securesettings.plugin.extra.ENABLED-type>
<com.intangibleobject.securesettings.plugin.extra.SETTING>gps</com.intangibleobject.securesettings.plugin.extra.SETTING>
<com.intangibleobject.securesettings.plugin.extra.SETTING-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.SETTING-type>
<com.twofortyfouram.locale.intent.extra.BLURB>GPS Enabled</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">com.intangibleobject.securesettings.plugin</Str>
<Str sr="arg2" ve="3">Secure Settings</Str>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act1" ve="7">
<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="act2" ve="7">
<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"/>
<Str sr="arg4" ve="3"/>
<Int sr="arg5" val="10"/>
<Str sr="arg6" ve="3">text/plain</Str>
<Str sr="arg7" ve="3"/>
<Int sr="arg8" val="0"/>
</Action>
<Action sr="act3" ve="7">
<code>129</code>
<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 on my way.";

if (dist) msg += "";

if (dur) msg += " I should be home in " + dur + ".";

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"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%HTTPL</lhs>
<op>7</op>
<rhs>0</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act4" ve="7">
<code>11820</code>
<Bundle sr="arg0">
<Vals sr="val">
<com.intangibleobject.securesettings.plugin.extra.BLURB>GPS Disabled</com.intangibleobject.securesettings.plugin.extra.BLURB>
<com.intangibleobject.securesettings.plugin.extra.BLURB-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.BLURB-type>
<com.intangibleobject.securesettings.plugin.extra.ENABLED>false</com.intangibleobject.securesettings.plugin.extra.ENABLED>
<com.intangibleobject.securesettings.plugin.extra.ENABLED-type>java.lang.Boolean</com.intangibleobject.securesettings.plugin.extra.ENABLED-type>
<com.intangibleobject.securesettings.plugin.extra.SETTING>gps</com.intangibleobject.securesettings.plugin.extra.SETTING>
<com.intangibleobject.securesettings.plugin.extra.SETTING-type>java.lang.String</com.intangibleobject.securesettings.plugin.extra.SETTING-type>
<com.twofortyfouram.locale.intent.extra.BLURB>GPS Disabled</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">com.intangibleobject.securesettings.plugin</Str>
<Str sr="arg2" ve="3">Secure Settings</Str>
<Int sr="arg3" val="0"/>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%NAV</lhs>
<op>2</op>
<rhs>No</rhs>
</Condition>
</ConditionList>
</Action>
</Task>
</TaskerData>

John Doe

unread,
Jul 21, 2015, 11:30:59 AM7/21/15
to tas...@googlegroups.com
Just for your information, you can use GeoTask plugin in order to get address information starting from lat and long. It's easier than to do an http request and parse the json. In addition you can work out the distance between points. These actions are free.

micheal vaughn

unread,
Feb 7, 2017, 10:54:20 PM2/7/17
to Tasker
I keep getting errors in the HOMEZ2 variable split. Not sure if I have the directions right. You said I must create 2 variable sets. %HOME and %HOMENUM. I did that. I put them in Line 1 and 2. In the HTTP GET there is a place that says, YOUR+ADDRESS+HERE. Do I put anything there?

micheal vaughn

unread,
Feb 9, 2017, 1:14:44 PM2/9/17
to Tasker
I finally figured it out. You must put a + for all spaces. It works now.
Example: 1037+Elk+St+Altus,+MS+46532

Thanks..

Duck Redbeard

unread,
Jun 8, 2017, 11:53:37 PM6/8/17
to Tasker
This isn't working for me anymore. I am getting an error on the javascript step…
Screenshot_20170608-235034.png

Jeremy Harris

unread,
Jun 10, 2017, 10:46:58 PM6/10/17
to Tasker
Here's how I do it:

Profile: Voice - Send My ETA (291)
Event: AutoVoice Recognized [ Configuration:Command: "send (?<contact>.+) my eta (regex)"
Last Cmd Id Regex: false
Last Cmd Id Invert: false
Not on Normal: false
Not on Continuous: false
Contains All: false
Use Regex Replacements: false
Do Google Now Search: false ]
Enter: Time To Destination (403)
A1: Secure Settings [ Configuration:AutoNotification: service.ServiceToastIntercept - Enabled Timeout (Seconds):0 ]
A2: AutoVoice Continuous [ Configuration:
Stopping continuous voice recognition
Persistent Notification: false Timeout (Seconds):0 ]
A3: Media Volume [ Level:15 Display:Off Sound:Off ]
A4: AutoContacts [ Configuration:Contact Name or Nickname: %contact Timeout (Seconds):1000 ]
A5: AutoNotification Query [ Configuration:App Name: Maps
Has Reply Action: false
Get All Fields : true Timeout (Seconds):20 ]
A6: Variable Split [ Name:%antexts2 Splitter:- Delete Base:Off ]
A7: Variable Set [ Name:%destination To:%antexts21 Recurse Variables:Off Do Maths:Off Append:Off ]
A8: Variable Set [ Name:%eta To:%antexts22 Recurse Variables:Off Do Maths:Off Append:Off ]
A9: Variable Search Replace [ Variable:%eta Search:[A-Z] Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In: Replace Matches:On Replace With: ]
A10: Variable Set [ Name:%destination To:home Recurse Variables:Off Do Maths:Off Append:Off ] If [ %antitle ~ 201 s 4th st ]
A11: Variable Set [ Name:%destination To:the office Recurse Variables:Off Do Maths:Off Append:Off ] If [ %antitle ~ 795 roble rd ]
A12: Send SMS [ Number:%acnumber Message:I'll be at %destination at %eta Store In Messaging App:On ]
A13: Flash [ Text:Text message was sent to %acname saying I'll be at %destination at %eta Long:On ]
A14: Say [ Text:Text message was sent to %acname saying I'll be at %destination at %eta Engine:Voice:default:default Stream:3 Pitch:5 Speed:5 Respect Audio Focus:Off Network:Off Continue Task Immediately:Off ]
A15: AutoVoice Continuous [ Configuration:
Starting continuous voice recognition without headset
Persistent Notification: false Timeout (Seconds):0 ]
A16: Secure Settings [ Configuration:AutoNotification: service.ServiceToastIntercept - Disabled Timeout (Seconds):0 ]

Duck Redbeard

unread,
Jun 11, 2017, 2:20:02 AM6/11/17
to Tasker
That is using autonotification plugin to extract data from a Maps notification. Only works if Maps is already navigating. I was wanting a stand-alone task.

Duck Redbeard

unread,
Jun 22, 2017, 12:07:21 PM6/22/17
to Tasker
I do not take credit for this.  Search google for "headed-home.xml" for the source.  I had used it in the past but it stopped working.  Not sure what I did to stop it, but I got it going again.  This is working for me now:

Create 2 variables:  %HOME will be your destination address in standard format (123 Tasker St, Android, NY 10001).  Commas and spacing might be crucial.  My address has a NE after the street name, but it is working fine without it.  The second variable is %HOMENUM which will be the intended recipient of your SMS message created by this task.

Here's the task:
Headed Home (325)
A1: Secure Settings [ Configuration:GPS Enabled Timeout (Seconds):0 ] 
A2: Get Location [ Source:GPS Timeout (Seconds):100 Continue Task Immediately:Off Keep Tracking:Off ] 
A3: HTTP Get [ Server:Port:maps.googleapis.com Path:maps/api/directions/json Attributes:origin=%LOC
destination=%HOME
sensor=false Cookies: User Agent: Timeout:10 Mime Type:text/plain Output File: Trust Any Certificate:Off ] 
A4: JavaScriptlet [ Code: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 = "ETA";

if (dist) msg += " ";

if (dur) msg += "should be about " + dur + " but traffic could only make it worse.";


var ok = sendSMS(global('HOMENUM'), msg);

flashLong("Sent message: " + msg); Libraries: Auto Exit:On Timeout (Seconds):45 ] If [ %HTTPL > 0 ]
A5: Secure Settings [ Configuration:GPS Disabled Timeout (Seconds):0 ] If [ %NAV ~ No ]

I have Secure Settings turn Location back to battery saving if the device is not currently using GPS for navigation.  That %NAV is set to yes on my device anytime I am actively using GPS for Waze, Maps, or Driving.

This task calculates my ETA from my current location to my home address and sends my wife an SMS formatted like this: "ETA should be about 1 min but traffic could only make it worse." I have it to be used in a profile that is triggered when only she sends me a text message that contains "eta". I also have a scene that contains a trigger so I can initiate the task.

On first test it calculated my commute to be 37 minutes.  Maps calculated it to be 33.  Reality was 37 minutes.  And that was through ATL in the rain.


Reply all
Reply to author
Forward
0 new messages