Tuesday, October 27, 2015

Navigation ETA Information Revisited - Revisited

I had hoped that my solution to the missing information in the Google Maps navigation notification would be a temporary one.  While it does work, it's definitely a kludge and I'm happy to be able to go back to gathering that content via AutoNotification.

Thanks to a user in one of the AutoApps forums, I learned that the ETA information is available in the variable %antextsbig4 under Lollipop. (Formerly it had just been in %antexts.)  With that knowledge I was able to re-do my profile and task and get them working again, so I thought I would post the solution here.


Profile: V3_ETAScrape (109)
Cooldown: 30
Event: AutoNotification Intercept [ Configuration:Event Behaviour: true
Persistency Type: Both
Notification Apps: Maps
Get All Fields : true ]
State: Variable Value [ %V3_DrivingMode Set ]

This is the profile itself.  It triggers when Google Maps puts up a notification AND the %V3_DrivingMode variable is set.  AutoNotification is set as the event handler and configured to look at both created and persistent notifications.  I've also set the flag so that AN will get all the fields in a notification.

The other thing to note is that there is a 30-second Cooldown set on the profile.  This keeps it from constantly firing as Maps updates the notification.  While it does reduce the granularity of the information somewhat, it keeps this profile from blocking other tasks and may make it a bit more stable.

When the profile fires, it gathers the information from the notification and populates a number of AN variables.  However, for this job we only need one of them: %antextsbig4.  It will contain data that looks something like this:

3.2 mi - Continue onto US 20

2 hr 52 min (165 mi) to destination
Estimated arrival at 2:39 PM

If I had enough room on my main screen, I could just display that info in a text box, but I really don't have that kind of real estate available to me, so I need to take it apart and shorten it up.

Enter: V3_NotificationQuery (102)
A1: Variable Set [ Name:%ret To:
Do Maths:Off Append:Off ] 

The first thing the entry task does is define the %ret variable.  Blogger doesn't show it, but the variable is filled simply by hitting the "Enter" key when you create the variable.  This is necessary because we need to split %antextsbig4 based on line returns and Tasker doesn't allow you to enter a return directly in the Variable Split action.

A2: Variable Split [ Name:%antextsbig4 Splitter:%ret Delete Base:Off ] 

As promised, we first use the %ret variable to split %antextsbig4 into its individual lines.  After the split, %antextsbig41 will contain the turn-by-turn info and %antextsbig42 will be a blank line.  I don't care about either of those, so they remain unused.

A3: Variable Split [ Name:%antextsbig43 Splitter:) Delete Base:Off ] 

%antextsbig43 contains the first line of the ETA information.  By splitting it with a parenthesis I can extract just the first part of the line and ignore the "to destination".

A4: Variable Split [ Name:%antextsbig44 Splitter:at Delete Base:Off ] 

Now I split %antextsbig44, which contains the second line of the ETA info. I use the word "at" as the splitter, which isolates the first part of the line,"Estimated arrival", and leaves me with just the arrival time. (Splitters never become part of a variable, so the "at" is gone as well.)

A5: Variable Set [ Name:%V3_ETA To:%antextsbig431)
ETA: %antextsbig443 Do Maths:Off Append:Off ] 

The last step is to populate the %V3_ETA variable, which serves as the source for my onscreen text display.  It's simply a matter of taking the parts of the lines I've split and concatenating them.  Note that I had to add the ) back in because it was used as the splitter in an earlier step and was, therefore, discarded out of the variable.


This is a pretty simple, but very useful addition to the Digital Dash project and I'm glad to have it working properly again.


6 comments:

Unknown said...

Just wanted to say thanks for this. I've be playing around with getting a car mode home screen sorted on my phone for a few weeks and stumbling across your blog, and this post in particular has helped me get close to where I want it. Not that I think I'll ever stop tweaking.

Mike said...

Thank you. Glad you found some of this useful. Good luck with your project.

Erik said...

I've tried these steps but no variables get set (antext or even antitle). When I select from current notifications, the name of it is just "Google apps" but I've also tried maps. Any thoughts? Other notification intercepts with other apps work.

Mike said...

Here's a very simple profile that I just created and tested that works for me:

Profile: MapIntercept (261)
Cooldown: 10
Event: AutoNotification Intercept [ Configuration:Event Behaviour: true
Persistency Type: Both
Has Reply Action: false
Notification Apps: Maps
Get All Fields : false
Get Internal Actions: false
Get Internal Actions Big: false ]
Enter: Flashnot (262)
A1: Flash [ Text:%antextbig Long:Off ]

If you recreate that does it work?

Erik said...

I created this profile but haven't gotten any ETA notifications from Google, and AFAIK there's no way to force trigger them?

I used another notification app and it picked up the ETA. It looks like it's called Google apps instead of maps. My original auto location profile didn't pick this up though - I may have had incorrect settings, so I'm trying again. But I can't trigger them so I'm just waiting...

Mike said...

You'll only get the notifications when you are in navigation mode and are actually getting directions to a destination. For AutoNotification, at least, the name of the app is indeed "maps" and you should be able to just choose it from the list. What OS are you on?