Skip to content

Nicxe/homeassistant-trafikinfo-se

Repository files navigation

Trafikinfo SE

Buy me a Coffee GitHub Release GitHub Downloads (all assets, all releases) GitHub Downloads (all assets, latest release)

Overview

Trafikinfo SE brings real-time Swedish road traffic information from Trafikverket into Home Assistant.

This repository now contains both:

  • The Home Assistant integration (trafikinfo_se)
  • The Lovelace alert card (trafikinfo-se-alert-card.js)

Prerequisites

Register at Trafikverkets API portal to get your API key.

Installation

Integration with HACS (recommended)

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

You can also add the repository manually in HACS as type Integration.

Integration without HACS

  1. Download trafikinfo_se.zip from the latest release.
  2. Extract the archive and place the trafikinfo_se folder in config/custom_components/.
  3. Restart Home Assistant.

Alert card installation

The alert card is bundled with this integration.

When the integration starts, it automatically:

  • syncs the bundled card to config/www/trafikinfo-se-alert-card.js
  • creates or updates a Lovelace module resource at /local/trafikinfo-se-alert-card.js?v=... for cache-busting

If you have just installed or updated, reload the browser once to ensure the latest card resource is loaded.

Card usage

The card can be configured in the dashboard UI editor:

  1. Open your dashboard.
  2. Select Edit dashboard.
  3. Add a new card.
  4. Search for and select one of:
    • Trafikinfo SE – Händelser (Olycka/Hinder/Vägarbete/Restriktion)
    • Trafikinfo SE – Restider
    • Trafikinfo SE – Viktig trafikinformation

You can also use the manual card types:

  • custom:trafikinfo-se-alert-card
  • custom:trafikinfo-se-route-card
  • custom:trafikinfo-se-viktig-trafikinformation-card

Manual fallback (if needed)

Normally no manual Lovelace resource setup is required.

If your dashboard does not load the card automatically, add this resource manually:

  • URL: /local/trafikinfo-se-alert-card.js
  • Type: JavaScript Module

Configuration

To add the integration, use this My button:

Add Trafikinfo SE to Home Assistant

If needed, add it manually via Settings > Devices & Services > Add Integration.

Entities provided by the integration

  • Olyckor
  • Hinder
  • Viktig trafikinformation
  • Restriktioner
  • Trafikmeddelande
  • Vägarbete

TravelTimeRoute support

The integration now supports Trafikverket's TravelTimeRoute data model as a separate route-focused setup flow within the same integration.

This mode is designed for commute-style monitoring, where the most important questions are how long a route takes right now, how much slower it is than normal, and whether traffic conditions are getting worse.

When you add a route entry, the integration creates route-specific sensors for:

  • current travel time
  • delay compared with free-flow traffic
  • current traffic status

The route data also includes geometry in WGS84, which the route card can use to draw the monitored road segment directly on a map.

Route card

The route card is available as custom:trafikinfo-se-route-card.

It supports both:

  • a single route sensor
  • multiple route sensors in the same card

When you add multiple route sensors, the card lists them one after another and can show all selected road segments on the same map. Each route line is color-coded from the sensor state so it is easier to scan the traffic situation for a whole area such as Gothenburg.

The route card can show:

  • current travel time
  • signed delay versus free-flow time
  • traffic status
  • update time
  • a shared map with route lines

The map is optional and intended for the detailed card view.

Automation triggers (event bus)

For sensors Hinder and Olycka, the integration emits one event per new or updated incident:

  • trafikinfo_se_hinder_incident
  • trafikinfo_se_olycka_incident

Each event includes fields such as incident_key, change_type, message_type, incident, and received_at.

Release assets and versioning

Each GitHub release in this repository publishes:

  • trafikinfo_se.zip for integration installation

The bundled alert card is included inside trafikinfo_se.zip.

The project uses one shared version across integration and card.

Commit conventions for release notes

Use Conventional Commits with component scopes for clear release notes, for example:

  • feat(integration): ...
  • fix(card): ...
  • chore(ci): ...

Migration from the old card repository

If you previously used homeassistant-trafikinfo-se-card, see MIGRATION.md.

Usage screenshots

trafikinfo example trafikinfo alert card CleanShot 2026-03-20 at 15 32 33

About

Home Assistant integration for Swedish road traffic events from Trafikverket’s Traffic Information API

Topics

Resources

License

Stars

Watchers

Forks

Contributors