Showing weather information for air and road temperature provided by Trafikverket in Sweden. This Python file should be used as a custom component in Home Assistant.
To enable this sensor, add the following lines to your configuration.yaml
.
sensor:
- platform: trafikverket_weatherstation
name: Trafikverket Road WeatherStation Kungälv
api_key: eXXcbXXXacXXXXc39XX3aXXX4aXX46XX
station: Kungälv
type: road
Configuration variables:
- name (Required): Unique name of the device in the frontend.
- api_key (Required): API key from Trafikverket
- station (Required): Name of the weather station
- type (Required): Defines which temperature you want (
air
orroad
) - scan_interval (Optional): How frequently to query for new data (in seconds). Defaults to 300 seconds (5 minutes)
https://api.trafikinfo.trafikverket.se/
sensor:
- platform: trafikverket_weatherstation
name: Trafikverket Road WeatherStation Kungälv
api_key: eXXcbXXXacXXXXc39XX3aXXX4aXX46XX
station: Kungälv
type: road
- platform: trafikverket_weatherstation
name: Trafikverket Air WeatherStation Lanna
api_key: eXXcbXXXacXXXXc39XX3aXXX4aXX46XX
station: Lanna
type: air
scan_interval: 600
A good practice is to use secrets.yaml
for all your API keys, username and password. You can read more about secrets here.