A status card for Home Assistant Lovelace UI for showing the current status of trains running from a station.
The card works with entities from within the sensor domain and is intended to be used with entities from the National Rail API Integration.
This card is not yet available in HACS (Home Assistant Community Store) directly but can still be added manually. HACS is a third party community store and is not included in Home Assistant out of the box.
-
Open HACS and navigate to Custom Repositories.
-
Select
Dashboard
as the Type and enterhttps://github.com/ChevronTango/nationalrail-status-card
as the repository. Save and refresh. -
Find
Nationalrail Status Card
in the HACS store and select install.
-
Download and copy
nationalrail-status-card.js
from the latest release into yourconfig/www
directory. -
Add the resource reference as decribed below.
-
Move into your
config/www
directory. -
Grab
nationalrail-status-card.js
:
$ wget https://github.com/ChevronTango/ha-nationalrail-status-card/releases/download/v0.0.1/nationalrail-status-card.js
- Add the resource reference as decribed below.
If you configure Lovelace via YAML, add a reference to nationalrail-status-card.js
inside your configuration.yaml
:
resources:
- url: /local/nationalrail-status-card.js?v=0.0.1
type: module
Else, if you prefer the graphical editor, use the menu to add the resource:
- Make sure, advanced mode is enabled in your user profile (click on your user name to get there)
- Navigate to Configuration -> Lovelace Dashboards -> Resources Tab. Hit orange (+) icon
- Enter URL
/local/nationalrail-status-card.js
and select type "JavaScript Module". (Use/hacsfiles/nationalrail-status-card/nationalrail-status-card.js
and select "JavaScript Module" for HACS install) - Restart Home Assistant.
-
Install the National Rail API Integration.
-
Add a new device from the National Rail API Integration with a source and destination station. Only trains with a direct connection from the source to the destination will appear. Trains that require an interchange will not display.
-
In your dashboard add a New Card and select the
National Rail Status Card
. -
Select the entity for your station and destination, and optionally choose the number of trains to display. Click Save.
Name | Type | Default | Since | Description |
---|---|---|---|---|
type (required) | string | v0.0.1 | custom:nationalrail-status-card . |
|
entity (required) | string | v0.0.1 | The entity being monitored | |
limit (optional) | number | v0.0.1 | The maximum number of trains to show at once. If absent then defaults to the API default. |
- Clone this repository into your
config/www
folder using git:
$ git clone https://github.com/ChevronTango/ha-nationalrail-status-card.git
- Add a reference to the card in your
ui-lovelace.yaml
:
resources:
- url: /local/nationalrail-status-card/dist/nationalrail-status-card.js
type: module
Requires nodejs
& npm
.
- Move into the
nationalrail-status-card
repo, checkout the dev branch & install dependencies:
$ cd nationalrail-status-card && git checkout dev && npm install
-
Make changes to the source code.
-
Build the source by running:
$ npm run build
-
Refresh the browser to see changes.
Make sure cache is cleared or disabled.
-
(Optional) Watch the source and automatically rebuild on save:
$ npm run watch
The new nationalrail-status-card.js
will be build and ready inside /dist
.
Note that the dev
branch is the most up-to-date and matches our beta releases.
Please refer to the Contribution Guidelines if you're interested in contributing to the project. (And thanks for considering!)
Make sure you have javascript_version: latest
in your configuration.yaml
under frontend:
.
Make sure you have the latest versions of nationalrail-status-card.js
& nationalrail-status-lib.js
.
If you have issues after updating the card, try clearing your browser cache.
If you have issues displaying the card in older browsers, try changing type: module
to type: js
at the card reference in ui-lovelace.yaml
.
This project is under the MIT license.