/homeassistant_nationalrailtimes_integration

A custom Home Assistant component to show next available trains to specific stops through the National Rail Darwin SOAP API.

Primary LanguagePython

National Rail Departure Times Integration Component by @crismc

Open your Home Assistant instance and start setting up a new integration.

Buy Me A Coffee

hacs release downloads

A custom Home Assistant component to show next available trains to specific stops through the National Rail Darwin SOAP API. For better visuals, to be used with the Home Assistant custom card homeassistant_nationalrailtimes_lovelace (https://github.com/crismc/homeassistant_nationalrailtimes_lovelace)

Creates a sensor for each station/destination, reporting arrival/destination times, and relevant calling stops along the way coupled with any station messages such as delayed or cancelled services.

Based on the HA-LondonTfl component by [@morosanmihail] (https://github.com/morosanmihail/HA-LondonTfL), although the internals have taken a side step to incorporate the Darwin SOAP API.

This can be used for any/all stations associated to the National Rail service, and returns service information associated to the GetNextDeparturesWithDetailsRequest. For information on the SOAP API, visit Live Departure Boards Web Service (LDBWS / OpenLDBWS)

Screenshot4

Screenshot3

Requirements

As this component intracts with the National Rail Darwin Feed, this requires an API Key to access the LDB Webservice (PV) SOAP API: https://www.nationalrail.co.uk/100296.aspx

Simply go to the above link and choose Register Here next to LDB Webservice (PV)

Options

Name Type Requirement Description Default
api_key string Required National Rail Darwin Feed API Key none
arrival string Required 3 Letter CRX station code of your local station none
destination string Required 3 Letter CRX station code of your target destination station none
time_offset string Required An offset in minutes against the current time to provide the station board for your local station none

Installing via HACS

The easiest way to install this integration component is to install via HACS:

  1. Simply go to HACS in your Home Assistant
  2. Select Integrations
  3. In the top right of the screen, select the 3 dots and choose 'Custom repositories'
  4. For the repository field enter 'https://github.com/crismc/homeassistant_nationalrailtimes_integration'
  5. Choose 'Integration' as the category
  6. Add
  7. Restart your HomeAssistant
  8. Add Integration or Explore & Download Repositories (depending on your version of Home Assistant)
  9. Search for 'National Rail Departure Times'
  10. Enjoy

Installing the component from source

Simply clone the repository, and manually drop the custom_components/nationalrailtimes directory it into your custom_components folder, and restart your Home Assistant configuration.

git clone git@github.com:crismc/homeassistant_nationalrailtimes_integration.git
cd homeassistant_nationalrailtimes_integration
cp -r custom_components/nationalrailtimes /your/homeassistant/conf/custom_components

Setup

Screenshot1

You can add integration via the Integrations menu by searching for National Rail Departure Times. It will ask for an API Key, provide a list of stations to set as your local arrival station, and allow you to set the time offset.

Screenshot2

Next, it will allow you to add your destination station. By selecting "Add Another", you can add more destination stations.

Each destination will be created as its own sensor.

Sensor name will change to the name of the local and destination station.

Alternate setup

Alternatively, you can set it up manually in your configuration.yaml.

If configuring this directly within configuration.yaml, you will also need to know your stations 3 letter CRX codes. These can be found here

Demo configuration:

sensor:
  - platform: nationalrailtimes
    api_key: 1234abcd-1a2b3c-1a2b-9876-123abc456def
    arrival: ABW
    destination: CHX
    time_offset: 20