Add documentation for here_travel_time (#9648)

* Add documentation for here_travel_time

* Add suggested changes to here_travel_time.markdown

* Update configuration options to latest fit parent

* Mention scan_interval explicitly

* ✏️ Tweak

* add mode: bicycle

* Add mode: publicTransportTimeTable

* Update to latest origin/destination options

* Remove reference to zone friendly name

* Update ha_release to 0.100

* floats are bad and I should feel bad

* ✏️ Tweaks
This commit is contained in:
Kevin Eifinger 2019-09-25 20:29:34 +02:00 committed by Franck Nijhof
parent 52416cc248
commit 7e0af7d2b0
2 changed files with 186 additions and 0 deletions

View File

@ -0,0 +1,172 @@
---
title: "HERE Travel Time"
description: "Instructions on how to add HERE travel time to Home Assistant."
logo: HERE_logo.svg
ha_category:
- Transport
- Sensor
ha_iot_class: Cloud Polling
ha_release: "0.100"
---
The `here_travel_time` sensor provides travel time from the [HERE Routing API](https://developer.here.com/documentation/routing/topics/introduction.html).
## Setup
You need to register for an API key by following the instructions [here](https://developer.here.com/documentation/routing/topics/introduction.html?create=Freemium-Basic&keepState=true&step=account).
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](https://developer.here.com/faqs#payment-subscription)
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](https://developer.here.com/faqs)
## Configuration
To enable the sensor, add the following lines to your `configuration.yaml` file:
```yaml
# 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 %}
app_id:
description: "Your application's API id (get one by following the instructions above)."
required: true
type: string
app_code:
description: "Your application's API code (get one by following the instructions above)."
required: true
type: string
origin_latitude:
description: "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`."
required: exclusive
type: float
origin_longitude:
description: "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`."
required: exclusive
type: float
destination_latitude:
description: "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`."
required: exclusive
type: float
destination_longitude:
description: "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`."
required: exclusive
type: float
origin_entity_id:
description: "The entity_id holding the starting point for calculating travel distance and time. Cannot be used in combination with `origin_latitude`/`origin_longitude`."
required: exclusive
type: string
destination_entity_id:
description: "The entity_id holding the finishing point for calculating travel distance and time. Cannot be used in combination with `destination_latitude`/`destination_longitude`."
required: exclusive
type: string
name:
description: A name to display on the sensor. The default is "HERE Travel Time".
required: false
type: string
default: "HERE Travel Time"
mode:
description: "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](https://developer.here.com/documentation/routing/topics/transport-modes.html) and on the public modes [here](https://developer.here.com/documentation/routing/topics/public-transport-routing.html)"
required: false
type: string
default: "car"
route_mode:
description: "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`"
required: false
type: string
default: "fastest"
traffic_mode:
description: "You can choose between: `true`, or `false`. Decide whether you want to take the current traffic condition into account. Default is `false`."
required: false
type: boolean
default: false
unit_system:
description: "You can choose between `metric` or `imperial`."
required: false
default: Defaults to `metric` or `imperial` based on the Home Assistant configuration.
type: string
scan_interval:
description: "Defines the update interval of the sensor in seconds. Defaults to 300 (5 minutes)."
required: false
type: integer
default: 300
{% endconfiguration %}
## 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.
```yaml
# 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:
```yaml
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
```

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg"
width="90"
height="82"
viewBox="0 0 90 82"
version="1.1">
<path
d="m 26.95,66.453001 -11,11 -11,-11 22,0 z"
style="fill:#65c1c2" />
<path
d="m 43.05,41.453001 c -2.3,-2.7 -2.2,-4.2 -0.8,-5.6 1.7,-1.7 3.5,-1 5.5,0.9 l -4.7,4.7 z m 23.6,-30 c 1.7,-1.6999994 3.5,-0.999999 5.5,0.9 l -4.7,4.7 c -2.4,-2.7 -2.3,-4.1 -0.8,-5.6 z m 14.2,4.8 c -2.1,3.2 -5.9,8.4 -9.8,4.5 l 9.9,-9.9 c -0.9,-0.8999994 -1.5,-1.6999992 -2.1,-2.1999992 -5.3,-5.3000001 -11.3,-5.4000001 -16,-0.7000001 -3.1,3.0999993 -4,6.6999993 -3.1,10.0999993 l -3.1,-3.5 c -0.8,0.4 -4.6,3.8 -1.8,8.8 l -3.5,-2.9 -4.7,4.7 6.4,6.4 c -4.9,-3.9 -10.2,-3.5 -14.4,0.7 -4.5,4.5 -4.2,10 -0.8,14.5 l -0.7,-0.7 c -4.5,-4.5 -9.4,-2.9 -11.8,-0.5 -1.9,1.9 -3,4.4 -2.5,6.2 l -9.7,-9.7 -5.2,5.2 19.2,19.2 10.3,0 -6.9,-6.9 c -3.6,-3.7 -3.7,-5.6 -1.9,-7.4 1.7,-1.7 3.7,-0.6 7.2,2.8 l 6.8,6.8 5.1,-5.1 -6.5,-6.5 c 4.7,3.5 10.3,3.7 15.3,-1.3 0,0 0.1,-0.1 0.1,-0.1 l 0,0 c 3.1,-2.8 4,-5.6 4,-5.6 l -3.9,-2.6 c -2.1,3.2 -5.8,8.4 -9.7,4.5 l 9.9,-9.9 6.2,6.2 5.4,-5.4 -7.7,-7.7 c -3.6,-3.6 -1.5,-7 0,-8.3 0.7,1.5 1.7,2.9 3,4.2 5,5 11.4,6 17.1,0.4 0,0 0.1,-0.1 0.1,-0.1 l 0,0 c 3.1,-2.8 4,-5.6 4,-5.6 l -4.2,-2.6 z"
style="fill:#393e47;fill-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB