Re: How to check the traffic and alert me if there is a problem?

3,685 views
Skip to first unread message

hollywoodfrodo

unread,
Jun 29, 2012, 10:09:33 AM6/29/12
to tas...@googlegroups.com
I don't think "alerting you if there is a traffic jam" is within Tasker's normal realm, though perhaps with some complex programming you could pull that info from the internet.  However, you can pretty simply create a scene with a map around a specific area (where you drive at that time) that shows traffic and have that scene automatically pop-up on your phone every weekday at 5pm so you can quickly see the traffic conditions and see if the freeways you normal travel have any issues.

On Thursday, June 28, 2012 6:31:29 PM UTC-7, Sean wrote:
Is there a way to get Tasker check the traffic between points A and B at a fixed time (e.g. 5pm every weekday), and alert me if there is a traffic jam?

Thanks!

dp106

unread,
Jun 29, 2012, 10:25:37 AM6/29/12
to tas...@googlegroups.com
Have you seen the traffic widget that comes with Google maps? You set the destination in the widget then it shows red green or amber based on the traffic. Doesn't do exactly what you ask but I use it to check how my journey is likely to be before I leave the office.

nanobrain

unread,
Jun 29, 2012, 11:02:12 AM6/29/12
to tas...@googlegroups.com
You didn't mention where you live, but in the US you could use traffic.com to send you scheduled alerts (either when traffic is bad or regardless of road conditions) either by phone call/email/SMS. In case of email/SMS you can use Tasker to parse email or SMS and notify you in any way you desire.

James Watkins

unread,
Feb 18, 2014, 12:19:49 PM2/18/14
to tas...@googlegroups.com
I've been tinkering with this idea as well.  On Google Maps I have two locations (home and work) and the website tells me the drive distance and time between the two points and also takes into account traffic delay time.  The website refreshes every time I go to it so I'm hoping if I can get Tasker to use the website via HTTP Get it'll also update automatically.  I've gotten this to work with Google Calendar so Tasker can read my next upcoming appointments and tell me the my next appointment date and time is.  I've been trying to get Tasker to use the Google Maps website via HTTP Get but when I view the source data I cannot find the drive time or distance for Tasker to use as a variable.  Anyone have a better solution for this?

easiuser

unread,
Feb 18, 2014, 3:58:02 PM2/18/14
to tas...@googlegroups.com
I perform an HTTP Get from google and parse it.  It is pretty easy to do.  Go to maps.google.com and enter your commute route.  Near the top there is a little link icon (next to the printer).  Copy the URL and use it in your HTTP Get and you should have the information you need.  In my case I do the following:

Split %data on In current traffic:
Split %data2 on min
%data21 should be travel time in minutes

Additionally you can split the original %data on dir-traffic-
and split %data2 on ">
%data21 should be green, yellow or red based on current traffic conditions.

I actually copied 3 links with different commute routes (both to and from work) and saved them to a file.  Then when I start the commute, Tasker reads in the routes, performs HTTP Gets, compares commute times and tells me the shortest route and estimated arrival time.

James Watkins

unread,
Feb 19, 2014, 4:53:29 AM2/19/14
to tas...@googlegroups.com
Awesome, that's exactly what I was trying to do.  Thank you very much. :)

James Watkins

unread,
Feb 20, 2014, 8:39:55 AM2/20/14
to tas...@googlegroups.com
Taking this a step further now, is there a way to edit the URL from Google so you can use your phone's GPS location rather than a static starting point?


On Tuesday, February 18, 2014 3:58:02 PM UTC-5, easiuser wrote:

easiuser

unread,
Feb 20, 2014, 10:45:38 AM2/20/14
to tas...@googlegroups.com

easiuser

unread,
Feb 20, 2014, 10:48:02 AM2/20/14
to tas...@googlegroups.com
Just create a variable that contains the coordinates like shown and use it in your HTTP Get.  You can put an address instead of the coordinates using + sign instead of spaces ie 200+main+street+city+state

James Watkins

unread,
Feb 20, 2014, 11:07:56 AM2/20/14
to tas...@googlegroups.com
Hm...  using the link from Chicago to LA and modifying a bit... I'd rather use Tasker's Get Location and use %LOC for the starting point.  I can then use the Lat/Long  or address of my destination accordingly.  

I haven't tried it yet but I'm thinking using:  https://maps.google.com/maps?saddr=%LOC+to:34.066312,-118.241944 "should" work to go from my phone's location to LA.  I'll try it when I get home from work today.

I sometimes travel to different places from different places for work and having the start point be more flexible like this is what I'm hoping to achieve.

What I'm currently working on is a dynamic auto alarm clock feature in Tasker.  It automatically sets itself to go off based off the set time I have to be at work the next morning based of my Google Calendar schedule, it takes into account necessary time I need to get ready, and now I'm adding in traffic time to compensate whether I need more or less time to leave in order to be at work on time.  So far everything has worked perfectly except for the traffic time feature, but hopefully this URL will work.

Thanks for the help!

easiuser

unread,
Feb 20, 2014, 11:53:39 AM2/20/14
to tas...@googlegroups.com
Sorry if I wasn't clear.  Chicago to LA was just an example to show you the format of the Get request.  You can put either lat,lon or address info in place of the coordinates.  I have used the technique you show below to update my ETA periodically during my commute and have my phone speak the new ETA if traffic conditions change.

James Watkins

unread,
Feb 20, 2014, 11:58:32 AM2/20/14
to tas...@googlegroups.com
No I understood you perfectly.  Using that format you posted I changed the URL to:

https://maps.google.com/maps?saddr=%LOC+to:301+Memorial+Medical+Pkwy+Daytona+Beach+FL 

in the Get request in order for my phone to get traffic info from my current location to my way to work.  Unfortunately Google maps isn't liking the %LOC variable in the starting point so I'm gonna try something different..

easiuser

unread,
Feb 20, 2014, 12:45:48 PM2/20/14
to tas...@googlegroups.com
It should work.  You will have to perform a Get Location and verify %LOC is set before you do the HTTP Get.

Matt R

unread,
Feb 20, 2014, 12:48:11 PM2/20/14
to tas...@googlegroups.com
%LOC should work there.  Maybe flash it before you do the Get request to make sure it has a (reasonable) value?

Matt

James Watkins

unread,
Feb 20, 2014, 12:57:00 PM2/20/14
to tas...@googlegroups.com
I have a Get Location right before the Get Request. The Get Request works only if %LOC is set. I'll try flashing %LOC to make sure it has a proper variable that Google Maps can use.

James Watkins

unread,
Feb 20, 2014, 4:55:30 PM2/20/14
to tas...@googlegroups.com
Flashing %LOC shows lat/long coordinates as expected.  Testing it at home now, heh yeah it's working as expected, guess when I was testing it the bad signal in the hospital was the problem.  Lol oh well.  Thanks for the help all!
Message has been deleted

Gabriel Ionita

unread,
May 7, 2014, 1:14:41 AM5/7/14
to tas...@googlegroups.com
Here is something similar. Maybe it helps. Now, I'm looking to get the time to leave. Input: %LOC or %LOCN, trafic from Google Maps and Google Caledar event start time and location.

Edited: Here is the link http://www.reddit.com/r/tasker/comments/1fmeq8/help_advanced_google_maps_traffic_information/

Louis Zampini

unread,
May 7, 2014, 9:24:17 AM5/7/14
to tas...@googlegroups.com
I have been able to get the data from %LOC to %HOME but I have an issue after that. It puts all the data in %HTTPD but then causes Tasker to crash. If I click on the VARS tab, Tasker quits and restarts before the last task was run. It was so bad that I had to export all my other tasks, uninstall Tasker, and delete my Tasker folder completely. Nothing else worked. Now I tried it again and the same thing happened.

Is there something I am missing? I know the data is being recorded since I flashed %HTTPD at the end of the task. How should I go about splitting the data to avoid this? 

Any tips would be helpful!


On Thursday, February 20, 2014 12:57:00 PM UTC-5, James Watkins wrote:

Matt R

unread,
May 7, 2014, 2:29:23 PM5/7/14
to tas...@googlegroups.com
Copy %HTTPD to a local variable first (e.g. Variable Set %data to %HTTPD).

Matt

Louis Zampini

unread,
May 13, 2014, 5:01:58 PM5/13/14
to tas...@googlegroups.com
Thank you for the suggestion. I still have an issue where after I set this up, I can no longer click on the VARS tab because it crashes Tasker. May not be related, but rolling it back to before I do an HTTP Get seems to fix the issue. Any ideas why this might be happening?

kinthiri

unread,
May 13, 2014, 5:24:24 PM5/13/14
to tas...@googlegroups.com
What you want has been asked and answered many times over.


It uses a script (provided) to get the details from Maps, but it does everything you're asking. Just a few minor changes to make it fit your needs.

Matt R

unread,
May 13, 2014, 6:11:51 PM5/13/14
to tas...@googlegroups.com
Are there any percent symbols (%) in the HTTPGet URL?  Also, I think when Tasker crashes, a crash log gets created somewhere in the Tasker folder.  Maybe look at that for clues (and post it for others to check)?

Matt

Eric

unread,
Nov 21, 2014, 8:45:44 AM11/21/14
to tas...@googlegroups.com
I have been using my variation of this task for awhile now. And I noticed the last two mornings my variables were not changing. It seems like the data being sent back is different now. I searched through the httpget file and I only see "traffic" once and no occurrences of "red", "yellow" or "green." Has anyone else experienced this? I just realized something is wrong so I haven't tried much yet but my variable splits are failing in the runlog because the splinter I use no longer exists in the new response. If anyone is familiar with the new data I would appreciate any help.

Corbin.

Louis Zampini

unread,
Nov 21, 2014, 2:00:11 PM11/21/14
to tas...@googlegroups.com
I have been experiencing extremely weird results in the past few days as well. I will be 1 minute away from by destination and it will tell me I am 1 h 43 min away.

Louis

On Fri, Nov 21, 2014 at 8:45 AM, Eric <ec05...@gmail.com> wrote:
I have been using my variation of this task for awhile now. And I noticed the last two mornings my variables were not changing. It seems like the data being sent back is different now. I searched through the httpget file and I only see "traffic" once and no occurrences of "red", "yellow" or "green." Has anyone else experienced this? I just realized something is wrong so I haven't tried much yet but my variable splits are failing in the runlog because the splinter I use no longer exists in the new response. If anyone is familiar with the new data I would appreciate any help.

Corbin.

--
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/CjJr42clMJc/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.

James Watkins

unread,
Nov 22, 2014, 3:56:22 PM11/22/14
to tas...@googlegroups.com
I've been experiencing a similar problem now too.  When Tasker runs my HTTP Get, it is no longer returning data back correctly anymore.  My variable splits are failing as well for the same reason.  I've sent the HTTP Get to an output file and it doesn't show nearly as much data as it used to.  The %HTTPD variable which is saved in a .txt file only goes up to 3K file size and Tasker says it only allows a max of 4K.  Reading the .txt file, my splinters I use no longer exists too.  Viewing the source from the website directly on my PC, it looks like Google added a lot more HTML which Tasker is not fetching.  I'm currently trying to figure out a way to correct this but I'm seriously drawing a blank right now...

nanobrain

unread,
Nov 23, 2014, 12:45:36 PM11/23/14
to tas...@googlegroups.com
As you found out Google has been modifying heavily their maps pages. In order to get traffic information I now use a HTTP GET of https://maps.googleapis.com/maps/api/directions/json?origin=youroriginaddress&destination=yourdestinationaddress&alternatives=true and the following javascriptlet

var text = [];
var reply = global('HTTPD');
var data = JSON.parse(reply); 
for (var i = 0; i < data.routes.length; i++){var road = data.routes[i].summary;
var duration = data.routes[i].legs[0].duration.text;
text[i] = road + ': '+ duration};

I then use %text() in an autonotification.

There is more information in the JSON file, like 'Warning' (possibly containing "x minutes longer than usual"?) that could be useful.   

easiuser

unread,
Nov 23, 2014, 11:14:07 PM11/23/14
to tas...@googlegroups.com
Unfortunately, I don't think the googleapis uses traffic data in the trip duration.  Their documentation indicates this requires the enterprise version "Google at Work".  Mapquest is currently supplying this information.  You need to get a key but there are unlimited requests.  This is whant I use.

//Local variables from task
var traveltime;
var fromloc;
var toloc;

var xmlHttp = null;


xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", path, false);
xmlHttp.send( null );

var response = xmlHttp.responseText;

var t = JSON.parse( response );

traveltime = t.route.realTime;

nanobrain

unread,
Nov 24, 2014, 9:03:40 AM11/24/14
to tas...@googlegroups.com
You're right. Looks like your solution is the way to go

nanobrain

unread,
Nov 26, 2014, 5:12:43 PM11/26/14
to tas...@googlegroups.com
Actually you can add "&output=classic" to the maps.google.com URL and it should give you the old style map, where the old method should still work. I like this method because it gives me the duration of the alternate routes as well

Eric

unread,
Nov 26, 2014, 5:49:29 PM11/26/14
to tas...@googlegroups.com
Hey thanks that's much simpler for me. I tried adding &output=classic at the very end of the Url and I still got the new response. Should I be adding an extra / or something?

nanobrain

unread,
Nov 26, 2014, 10:25:48 PM11/26/14
to tas...@googlegroups.com
Your URL should look something like this https://www.google.com/maps?saddr=1600+Pennsylvania+Avenue+Northwest,+Washington,+D.C.,+DC&daddr=Rockefeller+Plaza,+New+York,+NY&hl=en&output=classic

Eric

unread,
Nov 27, 2014, 1:35:32 PM11/27/14
to tas...@googlegroups.com
Thanks again the URL I was using was significantly different. I tried it with my addresses and got what looks like the old response but my variables aren't working correctly. I'll have to work on it when I get back to my computer and can look at the hole response on a larger screen.

easiuser

unread,
Nov 29, 2014, 8:14:52 PM11/29/14
to tas...@googlegroups.com
Just an FYI, the mapquest api also offers alternative routes by including maxRoutes=3 or any other number in the http request.  All the options are located here.  http://www.mapquestapi.com/directions/

Eric

unread,
Dec 14, 2014, 2:33:57 PM12/14/14
to tas...@googlegroups.com
I am definitely not a developer! But would someone be willing to point me in the right direction? I got a key to use and I have made a link using the sample thing on the developer page. The link in green below is the sample from http://www.mapquestapi.com/directions/  Where would I add in maxRoutes=3 like easiuser suggested? or useTraffic? If you could add it in a different color that would be wonderful. 

I'm willing to experiment but I don't know where to start. Thanks in advance. 

Corbin. 

Matt R

unread,
Dec 14, 2014, 4:01:50 PM12/14/14
to tas...@googlegroups.com
Add additional parameters using an & (ampersand).

Matt

easiuser

unread,
Dec 15, 2014, 9:35:21 AM12/15/14
to tas...@googlegroups.com
Just an additional note:  I have been receiving warnings from Mapquest that they are changing their pricing and traffic will not be part of the free version of the API.  I searched around and found that Microsoft of all places does provide traffic info in their free service.(at least as of now).  Check out http://www.bing.com/developers/s/APIBasics.html
 
You will need to get a key but the query is something like this:
 

Eric

unread,
Feb 18, 2015, 1:33:10 PM2/18/15
to tas...@googlegroups.com
It has been awhile but I made a work around last night that will serve my personal purposes. I thought it might be useful to others. It worked this morning but I have only used it once and I'll see if it works today before I drive home. I have my old android at home and was not using it so I decided to have it do all the work and send my new cell phone a notification while I am at work. I don't have the phone with me right now so I cannot post the description but I can post it later if people are intersted.

  • What I wanted:
    • Update the variable %Traffic every 2 minutes with the current Google maps traffic data before I leave for work and before I leave to come home.
      • This way I could make other notifications based on %Traffic changing from green to yellow to red.
  • What I did:
    • Old phone
      • Send intent from home to work to google maps app
      • use auto input to query the data
      • use an array function to pull out "light" "normal" or "heavy" traffic out of %aitext() from auto input.
      • change "light" "normal" and "heavy"to green yellow and red respectively
      • set %Traffic
      • use push bullet to notify my new phone.
    • New phone
      • receives %Traffic
      • creates notifications based on %Traffic.
        • ex. if %Traffic = red red red (one color for each of the suggested routes) and it is ten minutes before work is over then notify me of heavy traffic before leaving. 

So you need to have an old phone unless you are ok with having google maps launched every two minutes in your hands. And you have to keep the old phone charged. You may need to buy auto input for it to work because I forget what the limitations are on the lite version but the pro version of auto input is well worth it. I used pushbullet because I was already using it but I imagine autoremote would work just as well. Anyway this works for me I'm sure it would not be a good solution for someone making an app or something like that, I just wanted to share my solution.

Wesley Corwin

unread,
Feb 23, 2015, 5:06:44 PM2/23/15
to tas...@googlegroups.com
I think I'm having the same problem. Were you able to figure out the URL problem?
Reply all
Reply to author
Forward
0 new messages