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
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
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’
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.
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 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.
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!