GithubHelp home page GithubHelp logo

nwootton / mmm-uknationalrail Goto Github PK

View Code? Open in Web Editor NEW
18.0 3.0 14.0 268 KB

Magic Mirror Module for UK rail information. Returns departure info about a SPECIFIED UK rail station.

License: MIT License

JavaScript 93.60% CSS 6.40%
magicmirror uk-rail-info transport-api station

mmm-uknationalrail's Introduction

MMM-UKNationalRail

Additional Module for MagicMirror² https://github.com/MichMich/MagicMirror

Please note - I no longer run a MagicMirror, so this module is no-longer supported. Feel free to fork and update as necessary.

Module: UKNationalRail

This module displays LIVE train departures from the specified station(s).

Using the module

Git clone from this repository into the modules sub-directory of the Magic Mirror installation, change directory into the newly cloned code and then run npm install.

git clone https://github.com/nwootton/MMM-UKNationalRail.git
cd MMM-UKNationalRail
npm install

To use this module, add it to the modules array in the config/config.js file:

modules: [
    {
		module: 		'MMM-UKNationalRail',
		position: 		'bottom_left',
		header:			'Departures',		//Optional - delete this line to turn OFF the header completely
		config: {
			stationCode: 		'SUR', 		// CRS code for station
			app_id: 			'', 		// TransportAPI App ID
			app_key: 			'', 		// TransportAPI App Key
			maxResults: 		5,  		//Optional - Maximum results to display.
			showOrigin: 		false   	//Optional - Show the origin of the train in the table
		}
	},
]

There are 3 MANDATORY fields - stationCode, app_id and app_key. All the others are used to limit the amount of info you get back, especially useful for busy stations like Clapham Junction.

Add a config for each station you require info on

PLEASE NOTE The TransportAPI provides a sample key in their documentation that I previously referenced here. This is being removed very soon, so you MUST register to get this module to work!

The following is taken from the TransportAPI documentation here

Option Required Settings Description
stationCode String. The station you require information about.
This defaults to using the CRS format, but you can also specify the tiploc format by preceeding the code with 'tiploc:'

This value is REQUIRED
Example: SUR
Example: tiploc:GUILDFD
api_id String. Your TransportAPI app_id Get yours here.

This value is REQUIRED
Example: 03zf7118
app_key String. Your TransportAPI app_key Get yours here.

This value is REQUIRED
Example: z9307fd87b0000c107e098d5effedc97
Option Optional Settings Description
called_at String. Only include services that call at the given station, before calling at the station of interest.
It appears that you can't mix called_at with calling_at as it returns an empty response.

Example: 'THD'
calling_at String. Only include services that call at the given station, after calling at the station of interest.
It appears that you can't mix calling_at with called_at as it returns an empty response.

Example: 'EAD'
darwin Boolean. Additionally use data from the National Rail Enquiries Darwin Data Feeds when determining the value of the status fields for all the departures, arrivals or passes.

Default: false
destination String. Only include services terminating at the given station.

Example: 'WAT'
from_offset String. Modifies the start of the time window for which services are retrieved. By default, this is one hour in the past relative to the date/time of interest..

Default: '-PT01:00:00'
operator String. Only include services that are operated by the given operator, specified using its ATOC code

Example: 'SW'
origin String. Only include services originating from the given station.

Example: 'HMC'
service String. Only include services that have the given service code.

Example: '24673205'
to_offset String. Modifies the end of the time window for which services are retrieved. By default, this is two hours in the future relative to the date/time of interest.

Default: 'PT02:00:00'
train_status String. Only include services having the specified train status. Can be used to show either 'passenger' or 'freight' services.

Default: 'passenger'
type String. Only include services of the given type. Allowed types are "arrival", "departure" or "pass".
These individual values can be combined using a comma separated list of the allowed types such as:
"arrival,departure,pass" or "pass,departure".

Default: 'departure'
Option Other Settings
maxResults Integer. Limits the number of rows returned by the module. This will be the highest number between this value or the number of rows returned if it is less.

Default: 5
showOrigin Boolean. This shows the origin of the train in the results grid.

Default: false
showPlatform Boolean. This shows the platform number of the train in the results grid. If no platform is specified it will show '-'

Default: true

To find the CRS Station codes for the 'stations of interest' go here: http://www.railwaycodes.org.uk/crs/CRS0.shtm or use OpenStreetMap. Information on using OpenStreetMap is found inthe CRS.md file in this repo

Transport API

To setup an account for the App_id & app_key sign up for an account here: http://www.transportapi.com/

Troubleshooting

If there are issue getting data out of the module I'm ALWAYS going to ask the following:

  1. Do you have an account set up at Transportapi.com?
  2. Do you have an app_id and app_key set up?
  3. Do you know the CRS code for the station?
  4. If you use the live api documentation here and put in the info you want to use does it respond without an error?
  5. Is the info in your config the same as that you’ve used successfully in the live api docs?
  6. Include the Station CRS code in the report - each operator supplies information slightly differently. While TransportAPI does catch most of these, I might not have.

mmm-uknationalrail's People

Contributors

mattdy avatar nwootton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mmm-uknationalrail's Issues

Config for multiple stations

Hi. Your screenshot has multiple stations displayed, but the README does not indicate what config you use for setting that up. Can you clarify?

train times do not update

hello mate

I have got this up and running and have noticed that occasionally the train times wont update for some reason until I restart mm i.e. pm2 restart mm

Can you please look into this? As it has happened 3 times now on different days.

Thanks.

Trains showing as CANCELLED

I don't believe this is an issue with this module, but thought I should log it for reference.

My mirror is showing all trains as CANCELLED. Playing with the live docs on the TransportAPI's dev portal it is also returning status: CANCELLED. These trains are in fact running, as shown on National Rail, Trainline, etc.

I am a paid TransportAPI customer and have emailed support to report.

Request module deprecated?

I suspect that this module relies on a deprecated module. After upgrading my magic mirror core code, I get the following error:

[01.10.2021 18:49.04.563] [ERROR] App threw an error during load
[01.10.2021 18:49.04.568] [ERROR] Error: Cannot find module 'request'
Require stack:

  • /home/pi/MagicMirror/modules/MMM-UKNationalRail/node_helper.js
  • /home/pi/MagicMirror/js/app.js
  • /home/pi/MagicMirror/js/electron.js
  • /home/pi/MagicMirror/node_modules/electron/dist/resources/default_app.asar/main.js

Header being replaced by station name

Once the module has loaded, the header (e.g 'Arrivals') is replaced by the station name, so setting a header is essentially useless.
However, what would be great is if the set header could be combined with the station name instead.
So, for example, if my header is Arrivals from , it would become Arrivals from London Victoria.

I have added the module twice in my config - once showing the departures from my nearest station and once showing the arrivals and it's hard to distinguish between the 2 at the moment

No Longer Working

Seems as of the start of the month i can no longer get this extension to work.

All i have stuck on my display is "Loading trains"

Not appearing for some reason

To your troubleshoot questions

  1. YES
  2. YES
  3. YES (RDH)
  4. Sorry I'm a bit of a noob not sure what this is asking
  5. Same as previous
  6. So the code is RDH (redhill) trying to set this up for my girlfriends commute.

This app looks fantastic. I've had the magic mirror running for a while with a news feed, tube status (for our old address), local weather etc. I'm really not expert at this so I could be missing something obvious. Basically it just doesn't show up on the display. I've set position to 'middle_centre' put in crs and got the api id and key data input and double checked them. Any ideas? Thanks for your time!

Stuck on loading trains message

Module is loading but never gets past Loading Trains message. Details have been put in through the transport API site and return the 200 response expected. Have stripped back to the mandatory config fields only but no change.
config entry:
{
module: "MMM-UKNationalRail",
position: "bottom_left",
config: {
stationCode: "HUD",
app_id: "myAppId",
app_key: "myAppKey"
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.