Custom Component: here_travel_time

I can’t get this custom component to work. Tried to manually install the component and also using HACS. I’m running Hass.io, config check results in the following error:

Platform error sensor.here_travel_time - No module named 'herepy'

Re-starting is not possible…

On what version are you on? “Older” versions of hass.io have this problem.

Can you try to update manually e.g. via the command line?

Have you tried installing the module manually in your enviroment?

pip3 install herepy

I’m on the latest version.
I don’t think it’s possible to manually update via the command line on Hass.io, or is it?

I made it to work… Had to re-start Hass.io without adding the sensor, and added the sensor after that. :smiley:

Glad you could make it work!

Once 0.100 gets released this will be easier :sweat_smile:

Been there…
If you install the component using HACS and have not yet restarted HA yet, but nevertheless have added the configuration for the component in the configuration.yaml HA doesn’t recognize the component yet.
To circumvent this you should restart HA first and just then add the config to the configuration.yaml

Is my observation correct and is this component not accepting a input_select as an entitiy_id ?
I have created a automation rule which sets my destination based on the day of the week, my current location etc. My ultimate plan was to set this input_select as the destination_entity_id, but it does not seem to work…

Can you send me the details of your config and automation either here or via PM?
I want to make sure I understand you correctly. It seems you have brought up a new use case!

Great to see this in core now. So no config changes at all? Just remove the custom component?

Exactly.
I will also remove this from HACS once 0.100 is released.

1 Like

Couldn’t agree more. I don’t use HA betas but am really looking forward now to 0.100!

This has been a bit of a game changer for me for location. Here Maps is by far my favourite maps provider and has been since the early days of Windows Phone.

Thank you.

PS. For anyone who doesn’t know and hasn’t checked it out, the Here app (Android, and I assume ios too) allow you to download whole countries for offline use. Very useful when travelling. No, I have nothing to do with Here, I just think it is very good.

1 Like

Here is a stripped down version of what I created for this. (I removed some day related stuff. I work at geographically different office buildings throughout the week.)
My intention was to have it set automatically based on defaults while for example I can manually change my destination in the morning if I work at a different office today.

input_select:
  here_destination_preset:
    options:
      - zone.home
      - zone.office
      - zone.somewheredefault

sensor:
  - platform: here_travel_time
    app_id: my_app_id
    app_code: my_app_code
    name: Reistijd
    origin_entity_id: device_tracker.myphone
    destination_entity_id: input_select.here_destination_preset
    traffic_mode: true

automation:    
  - alias: 'set'
    trigger:
      - platform: homeassistant
        event: start
      - platform: time
        at: 00:00
    action:
       service: input_select.select_option
       data_template:
        entity_id: input_select.here_destination_preset
        option: "{% if is_state('device_tracker.myphone','home') %}zone.office{% elif is_state('device_tracker.myphone','office') %}zone.home{% else %}zone.somewheredefault{% endif %}"


You can get this to work quickly if you add an additional template sensor:

input_select:
  here_destination_preset:
    options:
      - zone.home
      - zone.office
      - zone.somewheredefault

sensor:
  - platform: template
    sensors:
      here_destination_preset:
        value_template: "{{ states('input_select.here_destination_preset') }}"

  - platform: here_travel_time
    app_id: my_app_id
    app_code: my_app_code
    name: Reistijd
    origin_entity_id: device_tracker.myphone
    destination_entity_id: sensor.here_destination_preset
    traffic_mode: true

automation:    
  - alias: 'set'
    trigger:
      - platform: homeassistant
        event: start
      - platform: time
        at: 00:00
    action:
       service: input_select.select_option
       data_template:
        entity_id: input_select.here_destination_preset
        option: "{% if is_state('device_tracker.myphone','home') %}zone.office{% elif is_state('device_tracker.myphone','office') %}zone.home{% else %}zone.somewheredefault{% endif %}"
1 Like

Well, now I get:

2019-10-04 22:53:20 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.reistijd fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 261, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 439, in async_device_update
    await self.async_update()
  File "/config/custom_components/here_travel_time/sensor.py", line 277, in async_update
    await self._hass.async_add_executor_job(self._here_data.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 361, in update
    origin, destination, [self.route_mode, self.travel_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 54, in _route
    'waypoint1': str.format('{0},{1}', waypoint_b[0], waypoint_b[1]),
IndexError: list index out of range

I have checked the state of the newly created template sensor. It should be OK:

sensor.here_destination_preset 	zone.mywork 	friendly_name: here_destination_preset

I will debug this tomorrow and get back to you as fast as possible.

I believe it is currently only supported to have the coordinates as a sensor value, not the name of another homeassistant entity.

New Release v2.1.0

Breaking Changes

Changes

Features

  • origin_entity_id and destination_entity_id can be any entity with its state being another entity_id or the coordinates themselves

Bugfixes


Please report any issues directly in the github repository: https://github.com/eifinger/here_travel_time/issues

@pathia
With version v2.1.0 your initital code should now work.
And you can also set an initial option for input_selects:

input_select:
  here_destination_preset:
    options:
      - zone.home
      - zone.office
      - zone.somewheredefault
    initial: zone.somewheredefault

I would be great if you can report back whether this works for you.

New Release v2.1.1

Fixes non working version v2.1.0

Breaking Changes

Changes

Features

Bugfixes

  • Fix error ATTR_MODE not found

Please report any issues directly in the github repository: https://github.com/eifinger/here_travel_time/issues

Thank you very much for the remarkably fast replies and update of the code. It worked. I don’t even need the template sensor. I am directly referencing the input_select entity. Now I can have this changed based on the day of the week along with my current location. The possibilities are endless. I could even change the destination based on my Google calendar entries. You ROCK!

1 Like

Thank you!
It was really hard to figure this one out, took me a few hours.
But reading a comment like this makes it worth a thousand times! :heart:

2 Likes