[B b65.ch](/)

![](https://www.b65.ch/images/efa-bus-timetable-home-assistant-hero.jpg)

On this page

10.09.2022

# Adding Efa Bus Timetable to Home Assistant

* * *

If you are using the [EFA bus timetable](https://www.efa.de/en/services/public-transportation/bus-timetables/) you can add a Departure Bus Timetable like this to your Home Assistant instance:

![](/images/timetable.png)

First up we need to configure a Rest Sensor in Home Assistant that will return the JSON response from the EFA API. Add this code to your configuration.yaml file. You will need to replace the "nameInfo\_dm" with your desired station ID. You can find a list of station IDs [here](https://www.efa.de/en/services/public-transportation/bus-timetables/).

`- platform: rest unique_id: '7ed6dfcd3dbc7544c7c880d265b4bc54' resource: https://www.efa-bw.de/bvb3/XML_DM_REQUEST?laguage=de&typeInfo_dm=stopID&deleteAssignedStops_dm=1&useRealtime=1&mode=direct&outputFormat=rapidJSON&limit=4&nameInfo_dm=53032154&version=10.5.17.3 scan_interval: 60 json_attributes: - "stopEvents" name: "Abfahrten"`

Then we need to add the sensor to our lovelace UI:

`type: vertical-stack cards: - type: custom:mushroom-title-card title: Abfahrten - type: horizontal-stack cards: - square: false columns: 2 type: grid cards: - type: custom:mushroom-template-card primary: >- {{state_attr('sensor.abfahrten','stopEvents')[0].transportation.destination.name}} secondary: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[0].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t > 0) %} in {{t | round }}' {% elif (t < 0) %} Verpasst {% elif (t > 59) %} Später {% elif (t > 120) %} Morgen {% endif %} icon: mdi:bus entity: sensor.abfahrten layout: horizontal tap_action: action: none hold_action: action: none double_tap_action: action: none icon_color: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[0].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t < 5) %} red {% elif (t < 9) %} orange {% elif (t > 8) %} green {% endif %} badge_icon: '' badge_color: '' - type: custom:mushroom-template-card primary: >- {{state_attr('sensor.abfahrten','stopEvents')[1].transportation.destination.name}} secondary: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[1].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t > 0) %} in {{t | round }}' {% elif (t < 0) %} Verpasst {% elif (t > 59) %} Später {% elif (t > 120) %} Morgen {% endif %} icon: mdi:bus entity: sensor.abfahrten layout: horizontal tap_action: action: none hold_action: action: none double_tap_action: action: none icon_color: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[1].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t < 5) %} red {% elif (t < 9) %} orange {% elif (t > 8) %} green {% endif %} badge_icon: '' badge_color: '' - type: custom:mushroom-template-card primary: >- {{state_attr('sensor.abfahrten','stopEvents')[2].transportation.destination.name}} secondary: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[2].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t > 0) %} in {{t | round }}' {% elif (t < 0) %} Verpasst {% elif (t > 59) %} Später {% elif (t > 120) %} Morgen {% endif %} icon: mdi:bus entity: sensor.abfahrten layout: horizontal tap_action: action: none hold_action: action: none double_tap_action: action: none icon_color: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[2].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t < 5) %} red {% elif (t < 9) %} orange {% elif (t > 8) %} green {% endif %} badge_icon: '' badge_color: '' - type: custom:mushroom-template-card primary: >- {{state_attr('sensor.abfahrten','stopEvents')[3].transportation.destination.name}} secondary: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[3].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t > 0) %} in {{t | round }}' {% elif (t < 0) %} Verpasst {% elif (t > 59) %} Später {% elif (t > 120) %} Morgen {% endif %} icon: mdi:bus entity: sensor.abfahrten layout: horizontal tap_action: action: none hold_action: action: none double_tap_action: action: none icon_color: >- {% set t = ((state_attr('sensor.abfahrten','stopEvents')[3].departureTimeEstimated | as_datetime - now()).total_seconds() // 60) %} {% if (t < 5) %} red {% elif (t < 9) %} orange {% elif (t > 8) %} green {% endif %} badge_icon: '' badge_color: ''`

I am using the "mushroom-template-card" from the [Mushroom](https://github.com/piitaya/lovelace-mushroom) repository.

And that's all there is to this.

Want departures without Home Assistant? Try [EFA-CLI](https://www.b65.ch/introducing-efa-cli-a-command-line-tool-for-public-transit-navigation.html) in your terminal or [EVA-PWA](https://www.b65.ch/eva-pwa-a-realtime-public-transit-pwa-for-basel.html) on your phone.

© 2026 Simon Jenny [Blog (Englisch)](/blog/index.html) [Kontakt](/contact.html)

- [**{{title}}**  
  {{excerpt}}](%7B%7Burl%7D%7D)