National Rail Integration Fork of jfparis

Hi Guys,

I have forked @jfparis national rail API and modified it. I have also created a custom card for my one.

Let me know your feedback. If it receives good feedback I will submit a pull request. My method uses different API calls so it will not work with the existing setups. (Maybe it should be kept seperate).

I would like to thank jfparis for his integration first

Integration:

Card:

@sleepy-salmon please post your issues/feature requests here

I have fixed the issue with multiple destination stations not being shown in the card. This was an issue in the integration. I have added the duration of travel to the card

I have also updated the integration to show a list of the CRS codes as station names. This will allow the selection of the station easier

1 Like

The duration works great!
For the multiple destination stations not being shown in the card, are you referring to the case where you add a card for a sensor which includes multiple destination stations? When I attempt this, I only get the last station as an option and none of the others.

I think that it was an HA Core update that I installed this morning, or maybe an OS update last night…
Anyway, the Integration no longer loads and I get a notification: ModuleNotFoundError: No module named ‘cgi’

what’s the difference, please? in features?

This has now been fixed. Please pull the latest

1 Like

I pull the arrival and departure times for for the stations and train location and display this info on a custom card. I have added more in to the config flow to allow you to select the stations easier.

My custom card shows the train location by clicking on the train row. I have updated to include duration of travel as requested by SleepySalmon. I do however need to update the readme’s on GitHub.

Any requests let me know.

I do want to state I wouldn’t have what I have is @jfparis didn’t do it first as I have expanded on his.

Yes, I was refereing to the multiple destinations. This was fixed in the integration, please confirm it works for you in the latest release

1 Like

I’ve been playing with the custom card today. The card now tracks trains based on time between stations and updates the location every 10 seconds (doesnt pull new data every 10s, this is every 10 mins). There is currently an issue when new data is pulled the card doesn’t revert to the original view. Will look into this.

This doesn’t affect the operation. Close the tracking and reopen it.

I can confirm that the multiple destinations is working now :ok_hand:

On your screenshot it shows the length of the train, is that something which is only provided by some operators?

I have noticed it doesnt always appear. The lengths comes from the API. I’ll have a look in to it

Could you pop up an example of the code for the card, please.

I have created a custom card for this. See the first post. It can be added by adding the repo in to HACS. It is customisable via the GUI.

If you dont use HACS, download the repo and add the js files in to the www folder in your config, and add the js to the recourses of the dashboard with /local/filename.js

If you need to add it in the yaml as you dont use the GUI configuration, Ill have a look later on tonight and the config and post an example

Thanks for the reply. I’ve downloaded via HACS and can see it as downloaded. However, when trying to add the card, it doesn’t appear in the list of cards I can add. I just assumed it was YAML config.

It should appear at the bottom of the list under custom cards.

Have you refreshed the browser cache/reloaded the app since installing?

If it still doesnt appear Ill try again on my one.

The yaml for mine is

type: custom:national-rail-card
arr_nDep: false
entity: sensor.train_schedule_lut_stp
station: STP
numRows: 5
grid_options:
  columns: 12
  rows: auto

Should be editable in the GUI as well.

I’ve updated by readme.md to show the details of the parameters

1 Like

Thanks! I’ve reloaded several times but no success. Maybe something wrong at my end but I can see other custom cards appearing.

Can you check hacs has added it to the resources list for the dashboard?

Settings → Dashboards → three dots (top right) → resources

Sorry getting this error when i add the integration -

res = await my_api.async_get_data()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  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

I finally got it working by re-downloading and re-booting. Using the GUI method of installing the card didn’t show any entries. However, I used your YAML code and I got it working. Thanks for helping me, it’s very much appreciated!