This custom-card is based on the integration ha-db_infoscreen developed by FaserF.
If you use this method your departureCard will always update to the newest version.
To install this custom card, follow these steps:
-
Download the card’s JavaScript file and add it to the /www/ directory in your Home Assistant instance.
-
Add the path to this card to your dashboard ressources (options -> dashboard -> three dots -> ressources):
resources:
- url: /local/departureCard.js type: javascript-module
- Use the example configuration above in your dashboard (manual yaml-configuration).
The following example demonstrates how to configure the card in your dashboard.
type: custom:departure-card
title: Köln Hbf
entity: sensor.koln_hbf_departures
connections_attribute: next_departures
displayed_connections: 8
unix_time: false
convertTimeHHMM: false
connection_properties:
targets: null
train: train
platform: platform
show_platform: true
departure: scheduledDeparture
delay: delayDeparture
isCancelled: isCancelled
stopAttribute: route
filterByStop: Köln Messe/Deutz
stationName: Köln Hbf
There are multiple ways you can filter and display connections.
If you want to see all connections with a specific final destination, you can filter your connections by target. This example shows all trains and busses with destination "Düsseldorf Hbf":
targets: Düsseldorf Hbf
If you want disable this filter and see all connections just set it to "null" or skip this line.
If you want to show only connections which have a certain stop, you have to make sure this information is provided by the api. Not for all stations those information are given.
You can check your entity with the template tool in the developer section of your home assistant.
{{ states.sensor.YOUR_ENTITY.attributes }}
Usually there should be an route[] item which contains a list of stops. You can use the stopAttribute if the list of stops are not displayed under route or if the name of the element is different. If it's route you can skip this line.
Since the list of stops contains all stops of the train, we need to know which stops are allready done and which stops are still to go. Therefor you have to provide the information of your stationName.
stationName: Köln Hbf
All stops before Köln Hbf will be ignored in the list of stops because those are not in the direction of travel.
Now you have to provide the name of the stop which you want to filter all remaining connections by.
filterByStop: Köln Messe/Deutz
You can skip those lines to disable this filter.
Specifies the type of card to display.
The title displayed at the top of the card.
The entity ID of the sensor that contains the departure data.
The attribute within the sensor data that holds the list of departures.
The number of connections (departures) to display.
Boolean flag that determines whether to convert Unix time format for timestamps. Check your sensor. If it shows something like 1737619740 it's unix-time.
Sometimes the timestamp given by the api appears like this "2025-01-26 20:12:00". Set convertTimeHHMM: true if you want to convert those timestamps into HH:MM.
Defines how each departure is displayed and which properties are included.
Targets for the connection. If no specific target is needed, set it to null.
The attribute from the sensor data that represents the train information.
The attribute from the sensor data where the train departs from.
Boolean flag to specify whether the platform number should be shown or not.
The attribute from the sensor data that contains the scheduled departure time of the train.
The attribute from the sensor that represents the delay of the departure.
The attribute from the sensor that contains the information if the train is cancelled.