Deutsche Bahn


The deutsche_bahn sensor will give you the departure time of the next train for the given connection. In case of a delay, the delay is also shown. Additional details are used to inform about eg. the type of the train, price, and if it is on time.

To enable this sensor, add the following lines to your configuration.yaml file:

# Example configuration.yaml entry
sensor:
  - platform: deutsche_bahn
    from: NAME_OF_START_STATION
    to: NAME_OF_FINAL_STATION

Configuration Variables

from

(string)(Required)The name of the start station.

to

(string)(Required)The name of the end/destination station.

only_direct

(boolean)(Optional)Only show direct connections.

Default value: false

This sensor stores a lot of attributes which can be accessed by other sensors eg. a template sensor.

# Example configuration.yaml entry
sensor:
  platform: template
  sensors:
    next_departure:
      value_template: '{{ states.sensor.munich_to_ulm.attributes.next }}'
      friendly_name: 'Next departure'

The data is coming from the bahn.de website.