Public Transport Connection Card - silviokennecke/ha-public-transport-connection-card GitHub Wiki

This card allows you to display the next upcoming public transport connections offered by a sensor.

I designed this card to work with sensors provided by the FaserF/ha-deutschebahn and akloeckner/hacs-hafas integration. As this card should also be able to work with similar integrations, not explicitly tested, you need to configure the correct attribute and property names, exposed by your sensor. In case you use one of the suggested integrations, the default configuration should already contain the correct values.

screenshot of sample configuration

Provided Cards

This integration provides two similar cards. Which one you use depends on how the integration provides the data.

  • Use public-transport-connections-card if your integration provides an attribute containing an a array of connections.
  • Use public-transport-connections-attributes-card if your integration only provides fixed attributes for the current and the next connection.

Both cards support configuration using the Home Assistant UI.

public-transport-connections-card

Sample Config

type: custom:public-transport-connections-card
title: Nächste Bahn
theme: deutsche-bahn
entity: sensor.hamburg_hbf_to_berlin_hbf
departure_station: Hamburg Hbf
arrival_station: Berlin Hbf
connections_attribute: departures # for ha-deutschebahn: departures, for hacs-hafas: connections
connection_properties:
  description: products
  departure_time: departure
  departure_delay: delay
  arrival_time: arrival
  arrival_delay: delay_arrival
displayed_connections: 3

Configuration Reference

key required type (or of attribute value) description
title N string a title that is shown in the card
theme N string the theme to use; currently supported: deutsche-bahn, homeassistant
entity Y string entity id of the sensor providing the next connection
departure_station N string a static name of the departure station
arrival_station N string a static name of the arrival station
tap_action N Action an action to be executed when the card is tapped (default: more-info)
connections_attribute Y string the attribute containing an array of connection objects
connection_properties Y object contains information about the property names, with more information about the connections;
description N string a description for the connection; might contain information about the train number or train type; for ha-deutschebahn the suggested value is products
departure_time Y string|time the departure time of the connection
departure_delay N number the current departure delay of the connection
departure_station N string the departure station name of the connection
arrival_time Y string|time the arrival time of the connection
arrival_delay N number the current arrival delay of the connection
arrival_station N string the arrival station name of the connection
displayed_connections Y number the maximum number of connections to be shown; minimum 1

public-transport-connections-attributes-card

Sample Config

type: custom:public-transport-connections-attributes-card
title: Nächste Bahn
theme: deutsche-bahn
entity: sensor.hamburg_hbf_to_berlin_hbf
departure_station: Hamburg Hbf
arrival_station: Berlin Hbf
attributes:
  description: products
  departure_time: departure
  departure_delay: delay
  arrival_time: arrival
  arrival_delay: delay_arrival
  next_departure_time: next_1
  next_arrival_time: next_1_arrival

Configuration Reference

key required type (or of attribute value) description
title N string a title that is shown in the card
theme N string the theme to use; currently supported: deutsche-bahn, homeassistant
entity Y string entity id of the sensor providing the next connection
departure_station N string a static name of the departure station
arrival_station N string a static name of the arrival station
tap_action N Action an action to be executed when the card is tapped (default: more-info)
attributes Y object contains attribute names of the configured entity, with more information about the connections; required if connections_attribute is not set
description N string a description for the connection; might contain information about the train number or train type; for ha-deutschebahn the suggested value is products
departure_time Y string|time the departure time of the current connection
departure_delay N number the current departure delay of the current connection
departure_station N string the departure station name of the current connection
arrival_time Y string|time the arrival time of the current connection
arrival_delay N number the current arrival delay of the current connection
arrival_station N string the arrival station name of the current connection
next_description N string a description for the next upcoming connection; might contain information about the train number or train type; for ha-deutschebahn the suggested value is products
next_departure_time N string|time the departure time of the next upcoming connection
next_departure_delay N number the current departure delay of the next upcoming connection
next_departure_station N string the departure station name of the next upcoming connection
next_arrival_time N string|time the arrival time of the next upcoming connection
next_arrival_delay N number the current arrival delay of the next upcoming connection
next_arrival_station N string the arrival station name of the next upcoming connection