MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    1. Home
    2. bnitkin
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.
    B
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 4
    • Groups 0

    bnitkin

    @bnitkin

    1
    Reputation
    6
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    bnitkin Unfollow Follow

    Best posts made by bnitkin

    • MMM-transitfeed - upcoming departure board for most transit agencies

      Description:

      MMM-transitfeed uses GTFS (General Transit Feed Specification) sources to generate a live departures board that works for most public transit agencies. Agencies decide whether to publish GTFS data, so YMMV. For instance, SEPTA publishes one file with regional rail routes, and a second with everything else. As long as both are imported in the config, queries for bus, regional rail, trolley, and subway lines all work.

      Using the configuration, you can specify which routes, stations, and directions to monitor. By default, the next three departures are shown, but that’s configurable too. The README has more detail on configuration options.

      GTFS is used by Google/Apple/etc to generate transit directions, and you can usually find download URLs on the transit agencies website. transitfeeds.com has an index with a ton of GTFS files, though warns they may be out of date.

      This is my first module with MagicMirror. I wanted a reference for when transit options were near me, and figured it’d be useful to other people. As far as I can tell, the other transit modules here are specialized to an agency; this one works with any GTFS source. (It is a little harder to find the source and get setup, though.)

      Screenshots:

      Screenshot of normal usage
      Screenshot of a station with many departures

      Download:

      [card:bnitkin/MMM-transitfeed]


      Version 1.0.0

      • Initial release
      • Search & display any number of stations, with filtering by route & direction
      • Highlights departures in the next 5 minutes (configurable)
      • Can either consolidate or show all terminii for multi-head routes
      • Display departures as wall time or in-X-minutes
      • Doesn’t currently support
        • Realtime updates
        • Holiday schedules
      posted in Transport
      B
      bnitkin

    Latest posts made by bnitkin

    • RE: MMM-transitfeed - upcoming departure board for most transit agencies

      @Nisnis39 I don’t have a great answer, but might have a solution.

      These folks talk about the same issue of pruning, and that GTFS isn’t really organized by month. Internally, it assigns services to weekly calendars, and gives each calendar an effective time.

      For instance, a train might depart Trenton at 2:00 and arrive in Philly at 3:00 on the Weekday calendar. And that calendar’s effective Monday-Friday from 3/3/2022-8/8/2023. So the next month of service is the same amount of data as the next 3 since it’s just the same trip over and over (unless Paris schedules change absolutely all the time).

      I think prefiltering will work for you. The Stackoverflow question mentions using Transitland to manipulate GTFS files.

      If you extract IDFM-gtfs.zip and look at agency.txt, it calls out a bunch of different Paris transit providers:

      agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone,agency_fare_url,agency_email
      IDFM:71,RER,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:55,Noctilien,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:93,TER,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:1046,Transilien,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:1069,Terres d'Envol,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:1051,Poissy - Les Mureaux,http://www.navitia.io/,Europe/Paris,,,,
      IDFM:65,Phébus,http://www.navitia.io/,Europe/Paris,,,,
      ...
      

      Transitland can prune the routes down to the agencies (or routes) you’re interested in. Since it’s written in Go it’s much faster than the npm gtfs library. The releases link above has compiled downloads for Windows & Linux.

      This will extract all routes served by IDFM:71 (RER) and IDFM:65 (Phébus). Replace with whichever agencies you’re actually interested in. It might work on the Pi or you might need a real computer:

      ./transitland-linux extract -extract-agency IDFM:71 -extract-agency IDFM:65 IDFM-gtfs.zip pruned.zip
      

      Once you have a pruned GTFS file, swap that into the MagicMirror config (note path instead of url):

            gtfs_config: {
               agencies: [
                  {
                     "path": "/path/to/pruned.zip",
                     // Excluding shapes makes loading faster.
                     exclude: ['shapes']
                  },
                  ...
      

      There are some shortcomings. The pruned file is a snapshot and won’t update if schedules change, and it’s obviously extra work.

      If you can find individual GTFS sources for the agencies that operate your routes, that’d be much easier. Merging ~100 agencies in the region together is a ton of data.

      You could also try fishing in the GTFS library for exclusions and optimizations. It supports excluding individual files (like shapes), but doesn’t seem to have filtering on route/agency/calendar at import-time. If you find something promising, let me know - I’m happy to take pull requests or try things out!

      posted in Transport
      B
      bnitkin
    • RE: MMM-transitfeed - upcoming departure board for most transit agencies

      @rnieto18 Thanks for reporting that! You’re doing everything right; there was a parsing disagreement between my script and Virginia Railway. You should be able to pull from main (or just restart magicmirror; I think it auto-updates?) and be back in business.

      GTFS supports calendars so transit agencies can report different service on weekdays vs weekends or special holiday service. That means a single GTFS trip usually corresponds to M-F service under the same trip ID. MMM-transitfeed looks up the calendar for each trip to generate daily schedules. Virginia Rail has a single calendar called Regular, but the trips reference other calendars like Summer and Day After Thanksgiving.

      My script was looking up those nonexistent calendars and crashing when it tried to extract service from them. I’ve fixed it to not examine calendars that don’t exist.

      Let me know if it works, or if you’re still having trouble!

      – Ben

      posted in Transport
      B
      bnitkin
    • RE: MMM-transitfeed - upcoming departure board for most transit agencies

      @0livia Thanks! I’d like to add realtime support, but the format’s a little harder to work with. It’d also be cool to add little bus/train icons, but I wanted to make sure the base thing worked first.

      posted in Transport
      B
      bnitkin
    • MMM-transitfeed - upcoming departure board for most transit agencies

      Description:

      MMM-transitfeed uses GTFS (General Transit Feed Specification) sources to generate a live departures board that works for most public transit agencies. Agencies decide whether to publish GTFS data, so YMMV. For instance, SEPTA publishes one file with regional rail routes, and a second with everything else. As long as both are imported in the config, queries for bus, regional rail, trolley, and subway lines all work.

      Using the configuration, you can specify which routes, stations, and directions to monitor. By default, the next three departures are shown, but that’s configurable too. The README has more detail on configuration options.

      GTFS is used by Google/Apple/etc to generate transit directions, and you can usually find download URLs on the transit agencies website. transitfeeds.com has an index with a ton of GTFS files, though warns they may be out of date.

      This is my first module with MagicMirror. I wanted a reference for when transit options were near me, and figured it’d be useful to other people. As far as I can tell, the other transit modules here are specialized to an agency; this one works with any GTFS source. (It is a little harder to find the source and get setup, though.)

      Screenshots:

      Screenshot of normal usage
      Screenshot of a station with many departures

      Download:

      [card:bnitkin/MMM-transitfeed]


      Version 1.0.0

      • Initial release
      • Search & display any number of stations, with filtering by route & direction
      • Highlights departures in the next 5 minutes (configurable)
      • Can either consolidate or show all terminii for multi-head routes
      • Display departures as wall time or in-X-minutes
      • Doesn’t currently support
        • Realtime updates
        • Holiday schedules
      posted in Transport
      B
      bnitkin