Coder Social home page Coder Social logo

mmm-vta-live's Introduction

MMM-VTA-Live

VTA Live

This a module for the MagicMirror. This module shows the arrival times for your local stop for any of the services in the Bay Area, CA monitored by 511.org (see below). This used an older API that only monitored the VTA, hence the name.

511.org

Data provided by 511.org

Installation

  1. Navigate into your MagicMirror's modules folder and execute git clone https://github.com/nigel-daniels/MMM-VTA-Live. A new folder MMM-VTA-Live will appear, navigate into it.
  2. Execute npm install to install the node dependencies.

Config

Prior to creating the config you will need to locate the stop_code of the station you want to monitor. This can be found by running a the Stops request once you have your own API key. Although this was written for use with the VTA This can be used for any service monitored by the 511.org APIs including the BART services. You can get an API Key from the 511.org site here.

To collect the data you need for the options you can use the 511.org site here or:

Operator Lookup

http://api.511.org/transit/gtfsoperators?api_key=xxxxxxxxxxxxxxxxxxxx

This returns the list of transit agencies covered, make a note of the Id for your local transit agency. For example, Bay Area Rapid Transit returns:

...
{
    "Id": "SC",
    "Name": "VTA",
    "LastGenerated": "2/18/2021 1:07:38 PM"
},
...

The value SC can then be used to find the local stop you want live data about.

Stop Code Looup

http://api.511.org/transit/stops?api_key=xxxxxxxxxxxxxxxxxxxx&operator_id=SC

This returns the list of stops an agency operates. For example:

...
{
    "id": "64772",
    "Extensions": {
        "LocationType": "0",
        "PlatformCode": null,
        "ParentStation": "PS_STJM"
    },
    "Name": "Saint James Station",
    "Location": {
        "Longitude": "-121.890805",
        "Latitude": "37.338358"
    },
    "Url": null,
    "StopType": "onstreetBus"
},
{
    "id": "PS_STJM",
    "Extensions": {
        "LocationType": "1",
        "PlatformCode": null,
        "ParentStation": null
    },
    "Name": "Saint James Station",
    "Location": {
        "Longitude": "-121.891543",
        "Latitude": "37.338314"
    },
    "Url": null,
    "StopType": "onstreetBus"
},
{
    "id": "64749",
    "Extensions": {
        "LocationType": "0",
        "PlatformCode": null,
        "ParentStation": "PS_STJM"
    },
    "Name": "Saint James Station",
    "Location": {
        "Longitude": "-121.892183",
        "Latitude": "37.338402"
    },
    "Url": null,
    "StopType": "onstreetBus"
},
...

In this case we get multiple potential entries, we get the parent station and two stops (one for each direction the trains can be going) in this case the north bound trains that we want to monitor use the id: 64749. Its this numeric code we use in the options below.

Config

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

Option Description
api_key Required This is the API key assigned to you by 511.org (see above).

Type: string
agency Required for non-VTA stops. This is the agency operating the service you are monitoring, this is the agency id for example, VTA is SC, BART is BA.

Type: string
Default value: SC
stop_code Required This the id of the station you want to monitor (see above).

Type: string
'stop_name' This is the name of the stop you are monitoring.

Type: string
Default value: ???
interval How often the status is updated. Be sure to follow the API usage guidelines when setting this.

Type: integer
Default value: 60000 // 1 minute

Here is an example of an entry in config.js

{
    module:    'MMM-VTA-Live',
    position:  'top_left',
    header:    'VTA Rail Arrivals',
    config:	 {
                api_key:   'xxxxxxxxxxxxxxxxxxxx',
				agency:		'SC',
				stop_code:   '64749',  
				stop_name: 'St James (North)',
				interval:  60000
                }
},

Dependencies

  • urllib (installed via npm install)
  • moment (installed via npm install)

Notes

Feel free to submit pull requests or post issues and I'll do my best to respond.

Thanks To...

mmm-vta-live's People

Contributors

nigel-daniels avatar dependabot[bot] avatar

Watchers

 avatar  avatar

mmm-vta-live's Issues

Impossible to run the module

Hello @nigel-daniels ,

I settled everything good. No issue during installation.
I put the api, station ID, etc..
And this is what I have on my Magic Mirror :
image

It do not show anything anymore.
FYI, this is the only module that I've got with clock. And by removing yours, everything works fine.
I've also installed many others transportation modules in the past, so i know how it works on API and station ID.
So sad..

Any issue ?
Kind regards,

  • Max

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.