• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-transitfeed - upcoming departure board for most transit agencies

Scheduled Pinned Locked Moved Transport
9 Posts 4 Posters 1.5k Views 4 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    bnitkin
    last edited by Dec 28, 2022, 2:58 PM

    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
    0 N 2 Replies Last reply Dec 29, 2022, 5:49 PM Reply Quote 1
    • 0 Offline
      0livia @bnitkin
      last edited by Dec 29, 2022, 5:49 PM

      @bnitkin cool module thank you. when i was building my mirror i wanted to ad another bus company schedule which uses GTFS.

      B 1 Reply Last reply Dec 29, 2022, 11:15 PM Reply Quote 0
      • B Offline
        bnitkin @0livia
        last edited by Dec 29, 2022, 11:15 PM

        @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.

        R 1 Reply Last reply Mar 24, 2023, 4:43 PM Reply Quote 0
        • R Offline
          rnieto18 @bnitkin
          last edited by Mar 24, 2023, 4:43 PM

          @bnitkin I am beating my head trying to get the Virginia Railway into this module.

          I went https://transitfeeds.com/p/virginia-railway-express/250 and pulled the link to the latest download. I added it to my config

          		   config: {
          				gtfs_config: {
          				agencies: [
          					{
          					"url": "https://transitfeeds.com/p/virginia-railway-express/250/latest/download",
          					exclude: ['shapes']
          					},
          				],	
          			},
          
          			// Route + station pairs to monitor for departures
          			queries: [
          				{route_name: "Fredericksburg Line", stop_name: "Lorton"},
          			],
          			showStationNames: false,
          			}
          

          I get no trips found yet. Check queries in the config if this persists. I can get this to work with your config in the readme.

          I have even looked at https://www.vre.org/sites/vre/assets/File/pdfs/MobileDevelopersGuideweb.pdf
          and tried http://www.vre.org/gtfs/google_transit.zip

          Any help would be appreciated!

          B 1 Reply Last reply Mar 26, 2023, 2:22 PM Reply Quote 1
          • B Offline
            bnitkin @rnieto18
            last edited by Mar 26, 2023, 2:22 PM

            @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

            R 1 Reply Last reply Mar 26, 2023, 4:57 PM Reply Quote 0
            • R Offline
              rnieto18 @bnitkin
              last edited by Mar 26, 2023, 4:57 PM

              @bnitkin said in 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

              Thank You!! works great now

              1 Reply Last reply Reply Quote 1
              • N Offline
                Nisnis39 @bnitkin
                last edited by Jun 13, 2023, 10:14 PM

                @bnitkin Hello,

                This is an awesome project and it’s pretty much what i’m looking for for my MagicMirror (we don’t have dedicated module for Paris :( ).

                I have an issue though, as Paris is a very large city and as all our transport are regrouped into one GTFS (for the 3 next month) we get a stop_time.txt with 9 millions lines which is too much too handle for my Raspberry.

                Would it be possible to add a limit to the line that are extracted as we don’t need the timetable for the next 3 month but at most for the next week.

                Here the link to the GTFS if you want to take a peak : https://data.iledefrance-mobilites.fr/explore/dataset/offre-horaires-tc-gtfs-idfm/files/a925e164271e4bca93433756d6a340d1/download/

                I’d be delighted if you could help me with this issue.

                Best regards

                B 1 Reply Last reply Jun 15, 2023, 6:43 PM Reply Quote 0
                • B Offline
                  bnitkin @Nisnis39
                  last edited by Jun 15, 2023, 6:43 PM

                  @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!

                  N 1 Reply Last reply Jun 15, 2023, 8:20 PM Reply Quote 0
                  • N Offline
                    Nisnis39 @bnitkin
                    last edited by Jun 15, 2023, 8:20 PM

                    @bnitkin Thank you, I’ll do as you instructed and will be pruning the GTFS in order to lighten it.
                    You’re right, except for road work, timetable don’t change a week to another.

                    Sadly individual GTFS source don’t exist anymore as the autority that manage transport in Paris has decided to centralize everything (for the best and the worst).

                    Thank you again :)

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Enjoying MagicMirror? Please consider a donation!
                    MagicMirror created by Michael Teeuw.
                    Forum managed by Sam, technical setup by Karsten.
                    This forum is using NodeBB as its core | Contributors
                    Contact | Privacy Policy