Trafikinfo SE, Real-time Swedish traffic alerts for Home Assistant

Hi everyone!

I’d like to share a new project I’ve been working on: Trafikinfo SE, a Home Assistant integration for Swedish traffic information from Trafikverket.

The integration lets you monitor real-time traffic events such as accidents, roadworks, restrictions, and important traffic messages directly in Home Assistant. Perfect if you want to get notified when something affects your daily commute, plan automations based on incidents, or simply keep an eye on the traffic situation in your area.

Home Assistant – Trafikinfo SE

Trafikinfo SE connects to Trafikverket’s open APIs and provides sensors for:

  • Accidents
  • Obstacles
  • Roadworks
  • Restrictions
  • Important traffic information
  • General traffic messages

You can use these sensors for notifications, automations, or dashboard visualization.

The integration can be installed via HACS as a custom repository.

4 Likes

Alongside the integration, I’ve also created a custom Lovelace card designed specifically to visualize traffic events in a clear and compact way on your Home Assistant dashboard.

I’m very interested in feedback from the community. Feature ideas, bug reports, and general thoughts are all more than welcome.

Hope this can make daily commuting and travel planning a bit smarter.

Happy automating!

2 Likes

This looks great. Will try it out in the coming days!

1 Like

So installed it. What’s the best way to get a notification with info for each new incident?

Something like this?

alias: Trafikolycka
trigger:
  - platform: event
    event_type: trafikinfo_se_olycka_incident
    event_data:
      change_type: added
action:
  - service: notify.mobile_app_din_telefon
    data:
      title: Trafikolycka!
      message: >
        {{ trigger.event.data.incident.message }} på {{ trigger.event.data.incident.road_number }} ({{ trigger.event.data.incident.road_name }}).
mode: single

I made a blueprint for notifications

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like

Added blueprint for notifiactions but havent had any incidents that would trigger it yet. However, how do I add other areas to monitor?

You need to make a entry for that area so it creates sensors for that

Tried it yesterday and didnt get it to work. Did the same today and woked fine. Thanks. Currently I am using map radius on web to determine what is included in radius. A feature that would be nice is to see the radius of the chosen distance visually when setting up the area to be monitored.

Also, setting up an area I can set it to a specific road. Thats great. So lets say I am interested in accidents on a specific highway i set that area to that highway name and as I understand it it will filter on that only. Then I set up an area for a city but that highway runs through that city, then I dont want to get notifications from the city notification and the highway notification when the areas overlap. Can I in a similar fashion exluded roads when setting up an area? Am i making sense?

Thanks for a great integration.

Home Assistant do not support displaying a radius in that way. The only place it seems possible is in the zone configuration. I looked into it, but I couldn’t find a good solution that didn’t require creating a zone first and then referencing that zone in the configuration, and that doesn’t feel optimal unfortunately.

You can specify more than one road within an area, so if you have a zone with, say, a 25 km radius around you, you can choose exactly which roads you want to include. Just separate them with commas in the configuration.

I haven’t added any support for exclusions, but there are ways to handle it. The simplest approach is probably to add a condition in your notification automation that checks the road attribute and makes sure it is not one of the specific roads you want to exclude.

The only time you need to create additional entries is when you want a different zone, for example around your cabin, your workplace, or similar, and it’s not covered by your current zone.

For example, I live in Gothenburg and have a 30 km radius, but only for the major roads around the city, and only when the accident has a high or very high impact.

1 Like

What’s the set update polling time in the new update?

I set 5 minutes when I could set it myself.

It is every 5 min

1 Like

thanks for this integration! i have set it up with radius but as i understand it, only one specific road (51) and that works for everything BUT trafikmeddelande. that includes all messages within the radius, but i can filter it in the card section. is this intended?

Not 100% sure what you mean here but I do not think so, will need to look in to this

In the integration settings i have chosen radius (65km) and then input the road number (51).

The integration will filter all BUT trafikmmeddelanden which seems to include all messages within the radius. So its not filtering as the others

In the card, i can input 51 again into road filter and that works for trafikmmeddelanden.

Is that clearer?

Traffic messages are currently not fully respecting the road filter configuration and do not display events from all roads. The reason is that the integration allows all events with safety_related_message == True to bypass the road filter, regardless of road.

The Trafikverket API sets this field for the majority of traffic message types, such as SpeedManagement and VehicleObstruction, which causes them to bypass the configured filter. Looking at this now, I agree that too many events are being allowed through.

I am working on a solution that combines a correct default behavior with a new configurable option, allowing users to choose how these messages should be handled. In addition, the safety_related_message value will be exposed for each event, and a sensor-level attribute will show the currently active configuration.

This will give users better control over how traffic messages tagged as safety_related_message by Trafikverket are handled.

2 Likes

Using the blueprint for notifications I would like to send messages to telegram since I think it works better for these kinds of notificiations. Would it be possible to handle those notifications as in regular automations with target etc. For telegram one is supposed to use notify.send_message and then target. This as far as I can tell doesnt work with the blueprint.

I can take a look at it when I get back home from some vacation, can you add a issue on GitHub please

Thanks, I will add an issue!

1 Like

So I have updated to latest blueprint but automation is not triggering although it should. I only have extra services as notification service ie telegram bot. I have no notify mobile app service.

I can find the following at the timestamp in the log where it should trigger the automation.

Loggare: homeassistant.components.automation.trafik_notifiering_redacted1
Källa: components/automation/init.py:772
integration: Automatisering (dokumentation, ärenden)
Inträffade först: 07:57:30 (3 förekomster)
Senast loggat: 16:30:21

Error rendering variables: UndefinedError: ‘has_service’ is undefined

Loggare: homeassistant.helpers.template
Källa: helpers/template/init.py:1757
Inträffade först: 24 mars 2026 kl. 18:26:36 (7 förekomster)
Senast loggat: 16:30:21

  • Template variable warning: ‘dict object’ has no attribute ‘country’ when rendering ‘{{ value_json.country }}’
  • Template variable error: ‘has_service’ is undefined when rendering ‘{% set ns = namespace(services=) %} {% for dev_id in (notify_devices_input | default()) %} {% set name = device_attr(dev_id, ‘name’) %} {% if name %} {% set ns.services = ns.services + [‘notify.mobile_app_’ ~ (name | slugify)] %} {% endif %} {% endfor %} {% set s = (notify_additional_services_raw | default(’‘) | string).replace(’;‘, ‘,’) %} {% for raw in s.split(’,‘) %} {% set target = (raw | trim) %} {% if target and ‘.’ in target %} {% set parts = target.split(’.‘, 1) %} {% if has_service(parts[0], parts[1]) %} {% set ns.services = ns.services + [target] %} {% endif %} {% elif target %} {% set ns.services = ns.services + [target] %} {% endif %} {% endfor %} {{ ns.services }}’

Loggare: homeassistant.components.automation.trafik_notifiering_redacted2
Källa: components/automation/init.py:772
integration: Automatisering (dokumentation, ärenden)
Inträffade först: 07:57:30 (3 förekomster)
Senast loggat: 16:30:21

Error rendering variables: UndefinedError: ‘has_service’ is undefined