Probably. Although …
How do you install / update it? HACS (I don’t use that)?
Does it prompts you for updates?
I think I had it installed as custom repo from HACS, but I don’t believe I got an update prompt.
I just updated manually today, (but should have looked first, apologies again).
I’ve been using this successfully - thanks all for the work on it. One thing my fairly basic skills haven’t allowed me to do is to create an ‘arrivals board’ for a given station. I live near a fairly small station which doesn’t have a huge number of trains through it but they do come from a range of departure points. Has anyone been able to show planned arrivals to a given station rather than tracking them by individual departure points? If so I’d love to see some code. Thanks
Love this integration and many thanks for the markdown card CarlBird provided - helped me understand a lot about how to query the attributes.
I’m a bit of a noob and wonder if there’s an easy way to show the trains sorted not by departure time but arrival time - i.e. not show a slow train before a faster train?
Thanks again.
Hi,
I’ve started using the NationalRailUK integration.
It works for me, but I don’t know how to set up a nice departures board from my station.
Do you know where I can find some step-by-step instructions on how to do this?
Currently it looks like this:
TIA!
Here. Make sure you have the custom:html-template-card installed from HACS. Then add a card to a dashboard. select type manual and then paste my code into the window. Make sure to edit the title and journey entities for your journey.
type: custom:html-template-card
title: Horley - City Thameslink timetable
ignore_line_breaks: true
content: >
<style> table {width: 100%;} tr:nth-child(even) { background-color:
#222222;} td, th {text-align: left;} td.dest {padding-left: 1em;} </style>
<table> <thead> <tr> <th>Destination</th> <th>Sch'd</th>
<th>Expt'd</th> <th>Platform</th> </tr></thead> {% if
states.sensor.train_schedule_hor_ctk and
(states.sensor.train_schedule_hor_ctk.attributes.trains | length) > 0 -%}
<tbody> {% for train in states.sensor.train_schedule_hor_ctk.attributes.trains
%}<tr>
<td>{{ train.terminus }}</td>
<td>{{ as_timestamp(train.scheduled) | timestamp_custom('%I:%M %p') }}</td>
<td>{% if train.expected is not string -%}
{{ as_timestamp(train.expected) | timestamp_custom('%I:%M %p') }}
{%- else -%}{{ train.expected -}}
{% endif %}</td>
<td>{{ train.platform }}</td>
</tr> {% for dest in train.destinations -%} <tr>
<td class="dest">{{ dest.name }}</td>
<td> </td>
<td>{% if dest.time_at_destination is not string -%}
{{ as_timestamp(dest.time_at_destination) | timestamp_custom('%I:%M %p') }}
{%- else -%}{{ dest.time_at_destination -}}
{% endif %}</td><td></td>
</tr> {% endfor -%} {%- endfor -%} {%- else -%} <tr><td>No
Trains</td></tr> {%- endif -%} </tbody> </table>
Here’s another one. This is a markdown card. Again, make sure to edit the journey entity. BTW, all mine are taken for other people’s I have seen and edited so credit should go to them.
{% set numrows = 5 %}
{% set data = states.sensor.train_schedule_hor_ctk %}
{% if data and (data.attributes.trains|length) > 0 %}
<u><b>Next Trains - {{ data.attributes.name.split('_')[2] }} to {{ data.attributes.name.split('_')[3] }} {% if data.attributes.next_train_expected is not string %}{% set due = as_timestamp(data.attributes.next_train_expected) - as_timestamp(now()) %}{% endif %}{% if due is defined %}({% if due > 600 %}<font color="orange">{% else %}<font color="red">{% endif %}{% if due > 60 %}{{ due|timestamp_custom('%M')|int+1 }} mins{% else %}Due now!{% endif %}</font>){% endif %}</b></u>
{% set ns = namespace(count=1) %}
{% for trains in data.attributes.trains %}
{% if ns.count <= numrows %}
<table>
<tr><td><b>Destination: </b></td><td>{{ trains.terminus }}</td></tr>
<tr><td><b>Scheduled: </b></td><td>{% if trains.scheduled is not string %}{% if trains.scheduled != trains.expected %}<s>{{ as_timestamp(trains.scheduled)|timestamp_custom('%H:%M') }}</s> {% if trains.expected is not string %}<i><font color="aqua">Expected: {{ as_timestamp(trains.expected)|timestamp_custom('%H:%M') }}</font></i>{% else %}<b>{% if trains.expected == 'Cancelled' %}<font color="red">{% else %}<font color="orange">{% endif %}{{ trains.expected }}</font></b>{% endif %}{% else %}{{ as_timestamp(trains.scheduled)|timestamp_custom('%H:%M') }}{% endif %}{% else %}<b>{% if trains.scheduled == 'Cancelled' %}<font color="red">{% else %}<font color="orange">{% endif %}{{ trains.scheduled }}</font></b>{% endif %}</td></tr>
<tr><td><b>Platform: </b></td><td>{% if trains.platform != none %}{{ trains.platform }}{% elif trains.expected == 'Cancelled' %}<font color="gray">N/A</font>{% else %}<font color="gray">Unknown</font>{% endif %}</td></tr>
<tr><td><b>Arriving: </b></td><td>{% if trains.destinations[0].time_at_destination is not string %}{% if trains.scheduled != trains.expected %}<i><font color="aqua">{% endif %}{{ as_timestamp(trains.destinations[0].time_at_destination)|timestamp_custom('%H:%M') }}{% else %}<font color="gray">{% if trains.destinations[0].time_at_destination == 'Cancelled' %}N/A{% else %}Unknown{% endif %}</font>{% endif %}</td></tr>
</table>
{% if ns.count <= (numrows-1) and (ns.count-data.attributes.trains|length) != 0 %}<br>{% endif %}
{% set ns.count = ns.count + 1 %}
{% endif %}
{% endfor %}
{% else %}
<u><b>Next Trains - {{ data.attributes.name.split('_')[2] }} to {{ data.attributes.name.split('_')[3] }}</b></u>
<i>No more trains!</i>
{% endif %}
The problem is that I don’t have it in HACS.
Only when I type html in the search bar I get the following:
In HACS I installed Lovelace HTML Jinja2 Template card and working now!
Thanks for your help!
Now I need to find an integration that will show me bus departures from stops near my house.
This is on my list to make. There is an goverment API for it, just havent gotten around to it. May have a look this weekend.
TFL also provide bus details 9n their API if youre in London.
I made a quick and dirty integration for it a while back
I think I need to add one file to make it available in HACS. Maybe tonight
Yes Im in London
I’m getting this error when I try to use this git, when i add the integration I get ‘unexpected error’ after pasting in the token and stations. - GitHub - plutomedia987/homeassistant_nationalrail
File "/config/custom_components/nationalrailuk/client.py", line 384, in async_get_data
raise NationalRailClientException("unexpected data from api") from err
custom_components.nationalrailuk.client.NationalRailClientException: unexpected data from api
David, please take this one over to my thread.
yes sure.
I want to add the HACS file when I have a moment and rework the config flow to enable bus stop lookup
There is a good existing London TFL integration here
I have combined that with this National Rail integration to make my departure board from my local train station (Putney) to Waterloo and also the buses from my nearest stop. It looks like this:
Their configuration workflow is way better (where I would like mine to be)