Custom Component: here_travel_time

HI,

testing the component, I was wondering if we can set a prefix in the config, so the created sensors get a default prefix. We can do so eg in life360, and I seem to recall another HA setting were we can do this natively. Cant find it right now… sorry.
Not sure if that applies to Here though, so please have a look if possible?
thanks

In contrast to life360 here_travel_time does only create one single sensor. You can define the name by providing the name property.
Does that answer your question?

Yes thanks, and no :wink:

Of course we can set each individual name, and yes, it will be a small effort to do so.

But assuming eg a config for origin device_tracker.me and destination zone.home I would like to name that Me to home…

Would be cool if the integration could have a global prefix setting so it would create the sensor.here_me_to_home with friendly_name Me to Home.

It would make it easy to distinguish the sensor from the other tracks sensors in the setup.

btw the native HA setting I referred to in the post above is entity_namespace: see https://www.home-assistant.io/docs/configuration/platform_options/#entity-namespace

Hahaha! I was just going to post entity_namespace…

ha yes, beat you to it :wink:

could we then do this:

sensor:
  - platform: here_travel_time
    entity_namespace: here
    app_id: !secret here_app_id
    app_code: !secret here_app_code
    name: Me to home
    origin_entity_id: device_tracker.me
    destination_entity_id: zone.home
#    destination_latitude: 59.2842
#    destination_longitude: 59.2642
#    mode: car bicycle, pedestrian, publicTransport, publicTransportTimeTable,  truck
    route_mode: fastest
    traffic_mode: false
#    unit_system: metric
#    scan_interval: 2678400 # 1 month

Try it but I bet you can.

Ok I will.
btw the prefix for life360 I referred to is something different, and has to do with the specificities of the integration Removed integration - Home Assistant

a better example would be the enhanced sun component by @pnbruckner I use with a entity_namespace: astral so all these sensors are distinguished from any other sensors the native system components create. Also, and that is more of a Lovelace frontend thingy, I can use that with the cool auto-entities cards for example, selecting all entities alike easily.

Hope this goes to :wink:
btw did I mention the Here travel time sensors display beatifully on the waze custom card. Don’t think I did.
Well they do!

edit

the namespace works perfectly! cool. Whats even better is that my Here sensors are initialized and populated directly after restart, while the Waze sensors take a long time to do so, up to a few minutes sometimes.

1 Like

Yeah I use it with sun2 as well and was going to post that as an example but you beat me above…

getting a lot of this lately:

2020-01-07 18:12:00 ERROR (MainThread) [homeassistant.components.here_travel_time.sensor] The state of device_tracker.life360_name is not a valid set of coordinates: not_home

shouldn’t this be handled in the component? or at least take it down to a warning?

This is actually the component itself giving this message. I did put in there as an error rather than warning because the entity (device_tracker.life360 in this case) gives a wrong input which means the next update can not work at all. In my point of view it could be a warning if the component could revert to some backup.

Now for the error itself:
Can you provide (also as a PM if you like) the complete state (including attributes) of device_tracker.life360 at the time of the error? If you have history enabled you should be able to track it down.

not sure if this is a wrong input, it will probably be no input, as the tracker might be turned off and simply hasn’t got gps coordinates (yet).

about the state in history: no I can’t, history never loads…

If you can somehow confirm that this is the case I would concur that the level of that logmessage should be WARNING

Hey… just got beta 0.104.0b0. and got my new API key to replave previous.
It’s working but getting errors in my log.

Log Details (ERROR)
Thu Jan 09 2020 11:37:13 GMT+1100 (Australian Eastern Daylight Time)
Update for sensor.travel_to_home fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 459, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/here_travel_time/sensor.py", line 304, 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 "/usr/src/homeassistant/homeassistant/components/here_travel_time/sensor.py", line 409, in update
    herepy.RouteMode[traffic_mode],
  File "/usr/local/lib/python3.7/site-packages/herepy/routing_api.py", line 131, in car_route
    return self._route(waypoint_a, waypoint_b, modes, departure)
  File "/usr/local/lib/python3.7/site-packages/herepy/routing_api.py", line 67, in _route
    response = self.__get(self.URL_CALCULATE_ROUTE, data, RoutingResponse)
  File "/usr/local/lib/python3.7/site-packages/herepy/routing_api.py", line 36, in __get
    json_data = json.loads(response.content.decode('utf8'))
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Thank you for using the beta and reporting this. Can you send me a PM with your config including the exact coordinates used?

yep.done. (10 chars lol)

'Hello,

I am getting the following error message: 2020-01-10 14:45:45 ERROR (MainThread) [custom_components.here_travel_time.sensor] Invalid credentials. This error is returned if the specified token was invalid or no contract could be found for this token.

Do you know what the problem is?

Regards,

Huub’

Have you read the last ~20 posts in this thread?
Which version of HA are you on?
Is this the first time you try to use here_travel_time?

Thanks, missed a post. It’s working now:-)

0.104 is released and with it the new api keys can be used. This means new users who want to use HERE for the first time are now able to use the integration again!

Been around these forums for almost two years but this must have flewn under the radar for me. I will most definitely try this!!! Thanks!