vasttrafik sensor will provide you traveling details for the larger Göteborg area in Sweden from the Västtrafik public transportation service.
You must create an application here 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
Add the data to your
configuration.yaml file as shown in the example:
# Example configuration.yaml entry sensor: - platform: vasttrafik key: YOUR_API_KEY secret: YOUR_API_SECRET departures: - from: Musikvägen
List of travel routes.
The data are coming from Västtrafik.
A full configuration example could look like this:
# Example configuration.yaml entry sensor: - platform: vasttrafik key: YOUR_API_KEY secret: YOUR_API_SECRET departures: - name: Mot järntorget from: Musikvägen heading: Järntorget lines: - 7 - GRÖN 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 or with
To retrieve the ID using
Login into the Västtrafik API and go to “Hantera nycklar” next to the application you created for Home Assistant.
Make a copy of your AccessToken and execute the following
curlcommand, replacing “<ACCESS_TOKEN>” and “<STATION_NAME>” as necessary:
curl -H "Authorization: Bearer <ACCESS_TOKEN>" "https://api.vasttrafik.se/bin/rest.exe/v2/location.name?input=<STATION_NAME>&format=json
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.
# 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