Skip to content

db-infoscreen Homeassistant fetching (superior of ha-deutschebahn)

License

Notifications You must be signed in to change notification settings

FaserF/ha-db_infoscreen

Repository files navigation

Logo

DB Infoscreen Home Assistant Sensor 🚆

A comprehensive departure board integration for Home Assistant.

HACS Default GitHub Release License


The db-infoscreen sensor provides detailed departure times and train information for a given station directly in Home Assistant. Aggregating data from multiple sources (primarily Deutsche Bahn IRIS-TTS), it offers a powerful and comprehensive departure board for stations across Germany and Europe.

📚 View the Full Documentation

Station Sensor

✨ Features

Feature Description
📋 Departure Board View next departures, delays, platforms, and train types.
👥 Train Occupancy View predicted load factor (1st/2nd class) where available.
🌍 Wide Coverage Supports DB and many local transport associations (via HAFAS/EFA).
⚙️ Highly Configurable Filter by direction, train type, specific platforms, and more.
💖 Favorite Trains Filter for specific "Favorite Trains" (Commuter Profile).
ℹ️ Detailed Attributes Access route info, warnings, platform changes (changed_platform), wagon order (wagon_order), wagon order summary (wagon_order_html), sector info (platform_sectors), facilities (facilities), real-time route progress (route_details), and unique trip ID (trip_id).

🛠️ Installation

1. Using HACS (Recommended)

This integration is available as a default repository in HACS.

  1. Open HACS.
  2. Search for db-infoscreen.
  3. Click Download.
  4. Restart Home Assistant.

Open HACS

Tip

HACS ensures you stay up-to-date with the latest API changes and bug fixes.

2. Manual Installation

  1. Download the latest Release.
  2. Extract the ZIP file.
  3. Copy the db_infoscreen folder into your <config>/custom_components/ directory.
  4. Restart Home Assistant.

⚙️ Configuration

  1. Go to Settings -> Devices & Services.
  2. Click Add Integration.
  3. Search for DB Infoscreen.

Add Integration

Configuration Options

Initial Setup: When adding the integration, you will be asked for the most important settings:

Option Type Required Description
station string Yes Station name (e.g. München Hbf), DS100 ID (e.g. MH), or EVA ID. The setup flow includes an autocomplete search to help find the correct official name.
data_source string No Backend source (DB, AVV, etc.). Default: IRIS-TTS.
next_departures int No Number of upcoming departures to display. Default: 4.
platforms string No Filter by comma-separated platforms (e.g., 1, 2, 5).
via_stations string No Filter by stations the train must pass through.
direction string No Filter by direction text (API dependent).

Options Menu (Configure): All other settings are available via the Configure button on the integration entry. They are grouped into:

  • General: Update Interval, Offset, Count.
  • Filter: Directions, Train Types (e.g. ICE), Exclusions.
  • Display: Text View, Mode (Departure/Arrival), Detailed Info.
  • Advanced: Custom API URL, Deduplication, Route Details.

Full Options List

Option Default Description
update_interval 3 Fetch interval in minutes. Minimum: 1 minute.
hide_low_delay False Hide departures with < 5 min delay.
drop_late_trains False Hide past departures even if they are delayed.
deduplicate_departures False Filter out duplicate entries.
detailed False Show extra attributes (messages, ids, keys, wagon order, etc.).
past_60_minutes False Show departures from the past 60 minutes.
keep_route False Keep full route (stopover) details in attributes.
keep_endstation False Keep departure if station is also the endstation.
custom_api_url - Use a private/custom API instance.
offset 00:00 Time offset for search (HH:MM or HH:MM:SS).
admode departure Display departure or arrival times.
excluded_directions - Exclude departures with specific direction (substring match).
ignored_train_types [] List of train types to ignore.
enable_text_view False Enable simplified text view for ePaper displays.

Warning

Limitations & Performance

  • Sensor Limit: You are limited to 30 sensors unless using a custom_api_url.
  • Update Interval: Minimum is 1 minute to prevent API bans/throttling.
  • Storage: Enabling detailed, keep_route, or a high number of next_departures can hit Home Assistant's state storage limits. See Issue #22.
  • Data Accuracy: Depends on the selected data_source.

📡 Data Sources

This integration allows fetching data from various backend sources via DBF.

👇 Click to expand the full list of supported Data Sources

Supported Data Sources

🇩🇪 Germany

  • IRIS-TTS (Deutsche Bahn) - Default / Recommended
  • AVV – Aachener Verkehrsverbund
  • AVV – Augsburger Verkehrs- & Tarifverbund
  • BEG – Bayerische Eisenbahngesellschaft
  • BSVG – Braunschweiger Verkehrs-GmbH
  • BVG – Berliner Verkehrsbetriebe
  • DING – Donau-Iller Nahverkehrsverbund
  • KVB – Kölner Verkehrs-Betriebe
  • KVV – Karlsruher Verkehrsverbund
  • MVV – Münchener Verkehrs- und Tarifverbund
  • NAHSH – Nahverkehrsverbund Schleswig-Holstein
  • NASA – Personennahverkehr in Sachsen-Anhalt
  • NVBW – Nahverkehrsgesellschaft Baden-Württemberg
  • NVV – Nordhessischer Verkehrsverbund
  • NWL – Nahverkehr Westfalen-Lippe
  • RMV – Rhein-Main-Verkehrsverbund
  • RSAG – Rostocker Straßenbahn
  • RVV – Regensburger Verkehrsverbund
  • SaarVV – Saarländischer Verkehrsverbund
  • VAG – Freiburger Verkehrs AG
  • VBB – Verkehrsverbund Berlin-Brandenburg
  • VBN – Verkehrsverbund Bremen/Niedersachsen
  • VGN – Verkehrsverbund Großraum Nürnberg
  • VMT – Verkehrsverbund Mittelthüringen
  • VMV – Verkehrsgesellschaft Mecklenburg-Vorpommern
  • VOS – Verkehrsgemeinschaft Osnabrück
  • VRN – Verkehrsverbund Rhein-Neckar
  • VRR – Verkehrsverbund Rhein-Ruhr
  • VRR2 – Verkehrsverbund Rhein-Ruhr
  • VRR3 – Verkehrsverbund Rhein-Ruhr
  • VVO – Verkehrsverbund Oberelbe
  • VVS – Verkehrs- und Tarifverbund Stuttgart
  • bwegt – bwegt

🌍 International

  • BART – Bay Area Rapid Transit
  • BLS – BLS AG
  • CFL – Société Nationale des Chemins de Fer Luxembourgeois
  • CMTA – Capital Metro Austin Public Transport
  • DSB – Rejseplanen
  • IE – Iarnród Éireann
  • LinzAG – Linz AG
  • PKP – Polskie Koleje Państwowe
  • Resrobot – Resrobot
  • Rolph – Rolph
  • STV – Steirischer Verkehrsverbund
  • TPG – Transports publics genevois
  • ZVV – Züricher Verkehrsverbund
  • mobiliteit – mobilitéits zentral
  • ÖBB – Österreichische Bundesbahnen

Note: To use HAFAS for stations also found in IRIS-TTS (e.g. "Frankenforst Kippekausen"), choose the specific backend or set hafas=1. See Issue #8.


📦 Migration from ha-deutschebahn

Direct migration is not possible due to API differences. The old integration supported "Start to Destination" routing, which db-infoscreen handles differently.

To replicate "Start -> Destination" behavior:

  1. Via Stations: Use via_stations to filter trains going through your destination or key stops.
  2. Platforms: Filter by platform if trains to your destination always use specific tracks.
  3. Two Sensors: Create two sensors (one for Start, one for typical changeover stations) to track complex routes.

📊 Usage & Examples

For a detailed set of examples including platform change alerts, occupancy warnings, and advanced filtering, check out our Automation Cookbook.

Basic Automations

Notify when the next train is delayed:

automation:
  - alias: "Train Delay Notification"
    trigger:
      - platform: template
        value_template: "{{ state_attr('sensor.station_departures', 'next_departures')[0]['delayArrival'] | int > 10 }}"
    action:
      - service: notify.mobile_app
        data:
          message: >
            The train to {{ state_attr('sensor.station_departures', 'next_departures')[0]['destination'] }}
            is delayed by {{ state_attr('sensor.station_departures', 'next_departures')[0]['delayArrival'] }} min.

Custom Template Sensors

Display next connection in HH:MM +Delay format: (Credit: kRew94 & kaffeetrinker71)

sensor:
  - platform: template
    sensors:
      next_train_formatted:
        friendly_name: "Next Train"
        value_template: >
          {% set conn = state_attr('sensor.uelzen_departures_via_hannover_hbf', 'next_departures') | selectattr('isCancelled', 'equalto', 0) | list | first %}
          {% if conn %}
            {{ conn.train }} at {{ conn.scheduledDeparture }}{% if conn.delayDeparture > 0 %} +{{ conn.delayDeparture }}{% endif %}
          {% else %}
            No connection
          {% endif %}

Result: "ICE 2935 at 07:15 +5"

👇 Advanced: Filter Connections by Destination (Start -> Destination)

(Credit: Kanecaine) This example demonstrates how to filter connections from a station (e.g. Berlin Hbf) to a specific target (e.g. Leipzig Hbf) that must be in the train's route.

{%- set my_station = "Berlin Hbf" -%}
{%- set target = "Leipzig Hbf" -%}
{%- set number = 0 -%}
{%- set connections = state_attr('sensor.berlin_hbf_departures', 'next_departures') | default([]) | selectattr('isCancelled', 'equalto', 0) -%}
{%- set valid_connections = namespace(connections=[]) -%}
{%- for connection in connections -%}
  {%- set route = connection.route | default([]) | selectattr('name', 'defined') | map(attribute='name') | list -%}
  {%- if my_station in route and target in route and route.index(target) > route.index(my_station) -%}
    {%- set valid_connections.connections = valid_connections.connections + [connection] -%}
  {%- endif -%}
{%- endfor -%}

{%- if valid_connections.connections | length > number -%}
  {%- set connection = valid_connections.connections[number] -%}
  {%- set product_raw = connection.train | default('Unknown') -%}
  {%- set product = product_raw | regex_replace('^(Bus).*|^([A-Z]{2})\\s?\\d*', '\\1\\2') | replace("S ", "S") -%}
  {%- set departure = connection.scheduledDeparture | default('--') -%}
  {%- set delay = connection.delayDeparture | default(0) | int -%}
  {{ product }} {{ departure }}{% if delay > 0 %} +{{ delay }}{% endif %}
{%- else -%}
  --
{%- endif -%}

JSON Data Structure

The integration attributes provide data in JSON format. Use this to build your own templates.

👇 View JSON Example
{
  "departures": [
    {
      "scheduledArrival": "08:08",
      "destination": "München-Pasing",
      "train": "S 4",
      "platform": "4",
      "delayArrival": 18,
      "messages": {
        "delay": [
          {"text": "delay of a train ahead", "timestamp": "2025-01-21T07:53:00"}
        ]
      }
    }
  ]
}

Frontend Cards

For a beautiful dashboard display, check out these custom cards:


🐛 Troubleshooting & Support

  • Reporting Issues: Please report bugs on GitHub Issues.

  • Debug Logging: To help diagnose issues, enable debug logging in configuration.yaml:

    logger:
       logs:
          custom_components.db_infoscreen: debug
    

❤️ Credits

About

db-infoscreen Homeassistant fetching (superior of ha-deutschebahn)

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

  •  

Contributors 8

Languages