HERE Travel Time


The here_travel_time sensor provides travel time from the HERE Routing API.

Setup

You need to register for an API key (REST & XYZ HUB API/CLI) by following the instructions here.

HERE offers a Freemium Plan which includes 250,000 free Transactions per month. For the Routing API, one transaction equals one request with one starting point (no multi stop). More information can be found here

By default HERE will deactivate your account if you exceed the free Transaction limit for the month. You can add payment details to reenable your account as described here

Configuration

To enable the sensor, add the following lines to your configuration.yaml file:

# Example entry for configuration.yaml
sensor:
  - platform: here_travel_time
    app_id: "YOUR_APP_ID"
    app_code: "YOUR_APP_CODE"
    origin_latitude: "51.222975"
    origin_longitude: "9.267577"
    destination_latitude: "51.257430"
    destination_longitude: "9.335892"

Configuration Variables

app_id

(string)(Required)

Your application’s API id (get one by following the instructions above).

app_code

(string)(Required)

Your application’s API code (get one by following the instructions above).

origin_latitude

(float)(Exclusive)

The starting latitude for calculating travel distance and time. Must be used in combination with origin_longitude. Cannot be used in combination with origin_entity_id.

origin_longitude

(float)(Exclusive)

The starting longitude for calculating travel distance and time. Must be used in combination with origin_latitude. Cannot be used in combination with origin_entity_id.

destination_latitude

(float)(Exclusive)

The finishing latitude for calculating travel distance and time. Must be used in combination with destination_longitude. Cannot be used in combination with destination_entity_id.

destination_longitude

(float)(Exclusive)

The finishing longitude for calculating travel distance and time. Must be used in combination with destination_latitude. Cannot be used in combination with destination_entity_id.

origin_entity_id

(string)(Exclusive)

The entity_id holding the starting point for calculating travel distance and time. Cannot be used in combination with origin_latitude/origin_longitude.

destination_entity_id

(string)(Exclusive)

The entity_id holding the finishing point for calculating travel distance and time. Cannot be used in combination with destination_latitude/destination_longitude.

name

(string)(Optional)

A name to display on the sensor. The default is “HERE Travel Time”.

Default value:

HERE Travel Time

mode

(string)(Optional)

You can choose between: bicycle, car, pedestrian, publicTransport, publicTransportTimeTable or truck. The default is car. For public transport publicTransportTimeTable is recommended. You can find more information on the modes here and on the public modes here

Default value:

car

route_mode

(string)(Optional)

You can choose between: fastest, or shortest. This will determine whether the route is optimized to be the shortest and completely disregard traffic and speed limits or the fastest route according to the current traffic information. The default is fastest

Default value:

fastest

traffic_mode

(boolean)(Optional)

You can choose between: true, or false. Decide whether you want to take the current traffic condition into account. Default is false.

Default value:

false

unit_system

(string)(Optional)

You can choose between metric or imperial.

Default value:

Defaults to metric or imperial based on the Home Assistant configuration.

scan_interval

(integer)(Optional)

Defines the update interval of the sensor in seconds. Defaults to 300 (5 minutes).

Default value:

300

Dynamic Configuration

Tracking can be set up to track entities of type device_tracker, zone, sensor and person. If an entity is placed in the origin or destination then every 5 minutes when the platform updates, it will use the latest location of that entity.

# Example entry for configuration.yaml
sensor:
  # Tracking entity to entity
  - platform: here_travel_time
    app_id: "YOUR_APP_ID"
    app_code: "YOUR_APP_CODE"
    name: Phone To Home
    origin_entity_id: device_tracker.mobile_phone
    destination_entity_id: zone.home
  # Full config
  - platform: here_travel_time
    app_id: "YOUR_APP_ID"
    app_code: "YOUR_APP_CODE"
    name: Work to Home By Bike
    origin_entity_id: zone.work
    destination_latitude: 59.2842
    destination_longitude: 59.2642
    mode: bicycle
    route_mode: fastest
    traffic_mode: false
    unit_system: imperial
    scan_interval: 2678400 # 1 month
    

Entity Tracking

  • device_tracker
    • If the state is a zone, then the zone location will be used
    • If the state is not a zone, it will look for the longitude and latitude attributes
  • zone
    • Uses the longitude and latitude attributes
  • sensor
    • If the state is a zone, then will use the zone location
    • All other states will be passed directly into the HERE API
      • This includes all valid locations listed in the Configuration Variables

Updating sensors on-demand using Automation

You can also use the homeassistant.update_entity service to update the sensor on-demand. For example, if you want to update sensor.morning_commute every 2 minutes on weekday mornings, you can use the following automation:

automation:
- id: update_morning_commute_sensor
  alias: "Commute - Update morning commute sensor"
  initial_state: 'on'
  trigger:
    - platform: time_pattern
      minutes: '/2'
  condition:
    - condition: time
      after: '08:00:00'
      before: '11:00:00'
    - condition: time
      weekday:
        - mon
        - tue
        - wed
        - thu
        - fri
  action:
    - service: homeassistant.update_entity
      entity_id: sensor.morning_commute