Include station ID's in vasttrafik integration (#15623)

Co-authored-by: Franck Nijhof <git@frenck.dev>
Co-authored-by: Franck Nijhof <frenck@frenck.nl>
This commit is contained in:
Thomas Tuffin 2020-12-01 20:14:31 +01:00 committed by GitHub
parent 845ae7e5c3
commit 220142044f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,11 +43,11 @@ departures:
required: false required: false
type: string type: string
from: from:
description: The start station. description: The start station name or ID.
required: true required: true
type: string type: string
heading: heading:
description: Direction of the traveling. description: The destination station name or ID.
required: false required: false
type: string type: string
lines: lines:
@ -80,3 +80,33 @@ sensor:
- GRÖN - GRÖN
delay: 10 delay: 10
``` ```
## Solving incorrect selected station problems
It is possible to use the full name of the station for the from/heading values, e.g., Musikvägen, Göteborg.
In cases where the wrong station is being selected, it is possible to provide the station ID instead. To do this you first need to retrieve the station ID either via Västtrafik's [API-konsole](https://developer.vasttrafik.se/portal/#/api/Reseplaneraren/v2/landerss) or with `curl`.
To retrieve the ID using `curl`:
1. Login into the Västtrafik API and go to "Hantera nycklar" next to the application you created for Home Assistant.
2. Make a copy of your AccessToken and execute the following `curl` command, replacing "<ACCESS_TOKEN>" and "<STATION_NAME>" as necessary:
```shell
curl -H "Authorization: Bearer <ACCESS_TOKEN>" "https://api.vasttrafik.se/bin/rest.exe/v2/location.name?input=<STATION_NAME>&format=json
```
3. In the output locate the key called "StopLocation", and under this key, you will find a list of stops. Copy the ID for your desired stop and use it in your configuration.
```yaml
# Example configuration.yaml entry using station ID as departure and station name as destination
sensor:
- platform: vasttrafik
key: YOUR_API_KEY
secret: YOUR_API_SECRET
departures:
- name: To the Iron Square \o/
from: 9021014004870000
heading: Järntorget
delay: 0
```