Custom Component: here_travel_time

You need to add it manually under settings.

2 Likes

Iā€™m from the UK and choose the pedestrian option for my walk to work to test. It takes me 15mins normally, my wife 20 mins and Here Travel says 37mins which is a shame that it is so far out.

As @VDRainer said in HACS under SETTINGS you have to add the repository url as a custom repository.

1 Like

I wanted to add some if logic to starting location with template sensor.

The sensor returns correct value but the travel time sensor does not show in HA. What could be wrong?

  - platform: template
    sensors:
       start_address_gosia:
         value_template: >-
            {%- if is_state("person.gosia", "home")  -%}
              52.200000,20.900000
            {%- else -%}
              device_tracker.gosia_moto_2
            {%- endif %}


  - platform: here_travel_time
    name: 'Travel time Gosia to City'
    app_id: xxxxxxxxxxxxxxxxxxx
    app_code: xxxxxxxxxxxxxxxxxxx
    origin: sensor.start_address_gosia
    destination: 52.230703,21.030476
    mode: publicTransport
    traffic_mode: true

Are there any errors in the log?

New Release: v1.1.0

Breaking Changes

  • Attribute distance in Kilometers instead of Meters to align with google_travel_time and waze_travel_time

Changes

Features

  • Added waze-like route attribute

Looking forward to your feedback

@Pirol62 I left duration as it is because it has a specific unit of measurement. If it would exceed 60 minutes it would suddenly break anything that expects a number.

Moreover I could not find out how Waze is generating its route info. In some cases it didnā€™t even make sense for me.
I implemented it so that it will list every route for which a number (L3075, A66, B455, I75) is found and if possible with its according road name. This can be a lot for long and/or complicated routes.
Let me hear how this works for you =)

Checking out the Route attribute - looks to be working for me!

Thanks for this addition!

DeadEnd

Route works great here too on sensors with fixed co-ords, but I have errors in the log on startup for the sensor with a device tracker, they werenā€™t there before the update. Checked and the device tracker (GPSLogger Integration) is working correctly.

Unable to find entity device_tracker.bpn7n184xxxxxxxx

here_travel_time: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/here_travel_time/sensor.py", line 212, in update
    self._here_data.update()
  File "/config/custom_components/here_travel_time/sensor.py", line 291, in update
    self.origin = self.origin.split(',')
AttributeError: 'NoneType' object has no attribute 'split'

Hi, that sounds logic to me. ImO the typical use case for this will be the road to work and back or to recurring locations around home, hence the duration in minutes will be at least better :slightly_smiling_face: and the road list will not be too long as well
I will test it out.

Thanks for your work

By the way: Iā€™m working with hacs. shall I reinstall or do you provide an update? ā€” got the update

I could reproduce it, working on a fix

ok, works perfect and very fast.
but one last request:

attribution: null
duration: 1065
distance: 18.207
route: L26 - Westring; L476 - Krefelder StraƟe; A44

please transform the duration from seconds to minutes :slight_smile:
in seconds it is really useless and difficult to display in lovelace

this is how in looks like with the waze custom card
image

Only error I get in log is:

Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/here_travel_time/sensor.py", line 121, in run_setup
    here_data)
  File "/config/custom_components/here_travel_time/sensor.py", line 152, in __init__
    self.update()
  File "/config/custom_components/here_travel_time/sensor.py", line 219, in update
    self._here_data.update()
  File "/config/custom_components/here_travel_time/sensor.py", line 305, in update
    [self.travel_mode, self.route_mode, traffic_mode],
  File "/usr/local/lib/python3.7/site-packages/herepy/routing_api.py", line 78, in car_route
    return self._route(waypoint_a, waypoint_b, modes)
  File "/usr/local/lib/python3.7/site-packages/herepy/routing_api.py", line 53, in _route
    data = {'waypoint0': str.format('{0},{1}', waypoint_a[0], waypoint_a[1]),
IndexError: list index out of range

Thank you for the logs.
I could reproduce it and will publish a fix soon.

Thanks, v1.1.1 makes the sensor work OK (I think so but Iā€™m still at home) but there is still this in the log on start up:

Unable to find entity device_tracker.bpn7n18426xxxxxx

Is this only at startup and after sometime the error disappears and the sensor works correctly?

Yes, think so. The sensor shows zero as Iā€™m.at home, Iā€™ll try today when go to work.

This behavior is normal. At Home-assistant startup some entities are not yet present. GPSLogger entities are created as soon as the first location is sent by the phone (I think). Until that happened the error message will appear.

The route attribute works well hereā€¦

One thing though; have you set a limit to the length less than the (I believe) built in one of 256 chars? I have a route that seems to have been cut off after 195 characters.

This particular route (UK) has the same road number repeated several times but with the name of the road (street) changing. Maybe your logic could build the route by either,

  1. ignoring any changes if the road number stays the same, or
  2. including the road number once and then listing the road/street names?

Option 1 would obviously have the greatest effect in reducing the character count and of course I donā€™t know how this might affect other regions that use different road number/name schemes.

For example here is the section of a route that is all on the A1 but the A1 is a very long and major road that changes its name several times.

A1 - Falloden Way; A1 - Aylmer Road; A1 - Archway Road; A1 - St John's Way; A1 - Sandridge Street;


Finally, would it be possible to have an optional unit system configuration option? As I said I live in the UK and we have suffer from schizophrenia when it comes to units. We are metric, except on the roads where we still use miles. This means that we are generally more comfortable discussing travelling distances in miles.

Given that this custom component ā€˜onlyā€™ replaces functionality that already existed elsewhere (which I was already reasonably happy with) the rewards for using it in my opinion far outweigh what I would have expected from it. So thanks once more for providing this and Iā€™d love to see it added to the core of HA.

From my point of view, I like exactly this feature, that the same route number is listed with its different street names which gives me the idea where to enter or exit that road. :wink:
And now itā€™s getting complicated. The possible solution:
The sensor should get an option ā€œdetailed_route_list: true/falseā€

So it is possible to create different sensors, detailed for short routes and something like grouped or merged for long distance routes
Even the distance unit could be set as an option.

another topic:

Do you have some more infos about the option trafic_mode?
From my former activities I know, that Here provides current traffic info as well as historical.
In telematics, it is known, that Here provides nearly perfect information even because of these historical traffic information.
I tried to find something out and only got this:
image

Do you know, if the mode option provides these accurateness as well?