Update documentation to align with new Västtrafik developer portal (#29477)

This commit is contained in:
Magnus Larsson 2023-10-27 16:50:37 +02:00 committed by GitHub
parent 2e27f04615
commit e9bee783d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,7 +13,7 @@ ha_integration_type: integration
The `vasttrafik` sensor will provide you traveling details for the larger Göteborg area in Sweden from the [Västtrafik](https://vasttrafik.se/) public transportation service.
You must create an application [here](https://developer.vasttrafik.se/portal/#/applications) to obtain a `key` and a `secret`. Make sure to also subscribe to the API by going to `Mina prenumerationer`, selecting your newly created application and the API `Reseplaneraren V2`.
You must create an application [here](https://developer.vasttrafik.se/applications) to obtain a `key` and a `secret`. Make sure to also subscribe to the API by clicking on `Prenumerera på nytt API`, and selecting the API `Planera Resa v4`.
Add the data to your `configuration.yaml` file as shown in the example:
@ -64,7 +64,7 @@ departures:
default: 0
{% endconfiguration %}
The data are coming from [Västtrafik](https://vasttrafik.se/).
The data is coming from [Västtrafik](https://vasttrafik.se/).
A full configuration example could look like this:
@ -88,18 +88,19 @@ sensor:
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`.
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/apis/13/v4) (using GET /locations/by-text) 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:
1. Login into the Västtrafik API and go to ["Applikationer"](https://developer.vasttrafik.se/applications)
2. Click "* Generera accesstoken", and then "Kopiera".
3. 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
curl -H "Authorization: Bearer <ACCESS_TOKEN>" "https://ext-api.vasttrafik.se/pr/v4/locations/by-text?q=<STATION_NAME>"
```
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.
4. In the output locate the key called "results", and under this key, you will find a list of stops. Copy the ID (gid) 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