Giter Site home page Giter Site logo

mmm-tfl-arrivals's Introduction

MMM-TFL-Arrivals

This a module for the MagicMirror.

This module gets real time arrival predictions for specific stops using the TfL API.

Installation

git clone https://github.com/ryck/MMM-TFL-Arrivals.git &&
cd MMM-TFL-Arrivals &&
npm install

Config

The entry in config.js can include the following options:

Option Description
app_id Required This is the App ID assigned to you on the TfL Open Data Portal. Details on how to request an App ID can be found here

Type: string
app_key Required This is the App key assigned to you on the TfL Open Data Portal. Details on how to request an App key can be found here

Type: string
naptanId Required A StopPoint id (station naptan code e.g. 940GZZLUAS). You can search for StopPoints IDs here

Type: string
updateInterval How often the arrival information is updated.

Type: integer
Default value: 1 min
fade Fade the future events to black. (Gradient)

Type: bool
Possible values: true or false
Default value: true
fadePoint Where to start fade?

Type: bool
Possible values: 0 (top of the list) - 1 (bottom of list)
Default value: 0.25
initialLoadDelay The initial delay before loading. If you have multiple modules that use the same API key, you might want to delay one of the requests. (Milliseconds)

Type: integer
Possible values: 1000 - 5000
Default value: 0
animationSpeed Speed of the update animation. (Milliseconds)

Type: integer
Possible values:0 - 5000
Default value: 2000 (2 seconds)
lateThreshold How many minutes is late?

Type: integer
Default value: 2 min
limit Number of departures to return.

Type: string
Default: 5
color Use some accent colors for due and late status

Type: bool
Possible values: true or false
Default value: true
debug Show debug information.

Possible values: true or false
Default value: false

Here is an example of an entry in config.js

{
	module: 'MMM-TFL-Arrivals',
	position: 'bottom_left',
	header: 'Bus Arrivals',
	config: {
		app_id: "$APPID",
		app_key: "$APPKEY",
		naptanId: "940GZZLUBLM", // StopPoint id
		animationSpeed: 1000,
		fade: true,
		fadePoint: 0.25, // Start on 1/4th of the list.
		limit: 5,
		initialLoadDelay: 0,
		color: true,
		debug: false
	}
},

Dependencies

  • axios (installed via npm install)

Thanks To...

mmm-tfl-arrivals's People

Contributors

dependabot-preview[bot] avatar ryck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

szech b1gg

mmm-tfl-arrivals's Issues

Filtering

Hi

Would it be possible to add "line" filtering to the package ? The API on the TFL website doesnt seem to be working as expected. (from https://blog.tfl.gov.uk/2015/12/07/unified-api-part-5-aot-arrivals-of-things/)

IE. https://api.tfl.gov.uk/StopPoint/naptanId/arrivals?mode=bus&line=XXX does not return only arrival times for bus XXX at naptanId

I have playeed around with your MMM-TFL-Arrivals.js file and have a very basic filter setup, under the
"processBuses: function(data)" section, to be as per below (added the first and last line below)

if(bus.lineName === "XXX") { this.buses.data.push({ stopName: bus.stationName, routeName: bus.lineName, direction: bus.destinationName, expectedDeparture: bus.expectedArrival, timeToStation: bus.timeToStation, modeName: bus.modeName }); };

Obviously this should be done cleaner and better, but I dont know how to

Thoughts ?

Thansk

api_key should be app_key

Using the default, no bus data is pulled back, and when checking debug and viewing the generated URL, an 'exceeded limit' error is seen. This is because the url is incorrect - api_key should be app_key

Stale data

I have tried this on 2 x different Magic Mirrors, so appears to be a bug than local configuration.
Bus stop 490014138S shows old cached data, however shows correct when data manual examined via CURL command.
Not sure why only this bus stop, but Northbound 490014138N works fine.

See example below: timestamp: "January 30, 2021 1:21 PM" Data shown is 2021-01-27

  • [Object
    data: Array(6)
    0: {stopName: "Woodcote Green", routeName: "127", direction: "Purley", expectedDeparture: "2021-01-27T09:58:33Z", timeToStation: 116, …}
    1: {stopName: "Woodcote Green", routeName: "463", direction: "Coulsdon South", expectedDeparture: "2021-01-27T10:01:12Z", timeToStation: 275, …}
    2: {stopName: "Woodcote Green", routeName: "127", direction: "Purley", expectedDeparture: "2021-01-27T10:07:26Z", timeToStation: 649, …}
    3: {stopName: "Woodcote Green", routeName: "S4", direction: "Roundshaw", expectedDeparture: "2021-01-27T10:17:42Z", timeToStation: 1265, …}
    4: {stopName: "Woodcote Green", routeName: "127", direction: "Purley", expectedDeparture: "2021-01-27T10:18:07Z", timeToStation: 1290, …}
    5: {stopName: "Woodcote Green", routeName: "463", direction: "Coulsdon South", expectedDeparture: "2021-01-27T10:18:28Z", timeToStation: 1311, …}
    length: 6
    proto: Array(0)
    message: null
    timestamp: "January 30, 2021 1:21 PM"
    proto: Object]

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.