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.

    Converting an old JS file into a module

    Scheduled Pinned Locked Moved Troubleshooting
    20 Posts 3 Posters 13.7k Views 3 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.
    • yawnsY Offline
      yawns Moderator @ooom416354
      last edited by

      @ooom416354
      Do you have a link to the old module?

      ooom416354O 1 Reply Last reply Reply Quote 0
      • ooom416354O Offline
        ooom416354 @yawns
        last edited by

        @yawns Sure, the code was added as part of jangellx’s mirror project.

        the actual JS file is located here

        https://github.com/jangellx/MagicMirror/blob/master/js/mm-mta.js

        1 Reply Last reply Reply Quote 0
        • yawnsY Offline
          yawns Moderator
          last edited by

          Okay, looks rather simple. Do you want to develop it yourself and just need a push into the right direction? Or do you want one of us to do the conversion?

          ooom416354O 1 Reply Last reply Reply Quote 1
          • ooom416354O Offline
            ooom416354 @yawns
            last edited by

            @yawns I think maybe if you guys are able to do the conversion I can then dive in and figure out how to go from one to the other. If I try to do it I think I’d get stuck too many times as I am pretty poor in JS. I really appreciate it!

            yawnsY 1 Reply Last reply Reply Quote 0
            • cowboysdudeC Offline
              cowboysdude Module Developer
              last edited by

              Looks like it just needs a vehicle to display the info in the MM…

              ooom416354O 1 Reply Last reply Reply Quote 0
              • ooom416354O Offline
                ooom416354 @cowboysdude
                last edited by

                @cowboysdude for the old MM we ended up using the other function that the developer wrote to refresh and display it on the page. I’m just not sure how I can display it on the MM2 or what I’d need to rewrite to get it to work.

                cowboysdudeC 1 Reply Last reply Reply Quote 0
                • yawnsY Offline
                  yawns Moderator @ooom416354
                  last edited by yawns

                  @ooom416354
                  ok. Do you have an api key you could provide to me via chat/pm? Then I don’t need to request an own one just for testing purposes

                  Nevermind, I got one :)

                  1 Reply Last reply Reply Quote 1
                  • cowboysdudeC Offline
                    cowboysdude Module Developer @ooom416354
                    last edited by

                    @ooom416354 If you know js it’s easy…

                    https://github.com/MichMich/MagicMirror/tree/develop/modules

                    ooom416354O 1 Reply Last reply Reply Quote 0
                    • ooom416354O Offline
                      ooom416354 @cowboysdude
                      last edited by

                      @cowboysdude problem is I am so new to it and I don’t really know the best way to test without actually uploading everything to the Pi. I was using notepad++ to write but for testing I had used xampp for the MM1. That doesn’t work with node I don’t think right? I am a programmer but work mostly as a SQL developer so I never had a need for learning JavaScript. Is there any particular class, site, etc. I can start out with to learn and actually develop myself? Thanks.

                      1 Reply Last reply Reply Quote 0
                      • yawnsY Offline
                        yawns Moderator
                        last edited by

                        @ooom416354
                        Could you please tell me your sStation code? I just did some testing with the JSON and noticed I don’t get up-to-date data.
                        When I run this I always get data from this morning: https://traintime.lirr.org/api/Departure?loc=CLP&api_key=XXXXXXXXXXXXXXXXX

                        I need to take a closer look into this later.

                        ooom416354O 1 Reply Last reply Reply Quote 1
                        • ooom416354O Offline
                          ooom416354 @yawns
                          last edited by

                          @yawns yes that’s the local station to my house, CLP. The morning ride is CLP to NYK then reverse in the afternoon. It should show the closest train departures and if there’s a delay so this morning would make sense (there were no delays today that I know of). So when I test I would just set a delay of like 8 minutes to see if anything showed up.

                          yawnsY 1 Reply Last reply Reply Quote 0
                          • yawnsY Offline
                            yawns Moderator @ooom416354
                            last edited by

                            @ooom416354
                            Do you know of a list of all stations with their LOC code for api requests? They have a list of stations, but I can’t find the codes

                            ooom416354O 1 Reply Last reply Reply Quote 0
                            • ooom416354O Offline
                              ooom416354 @yawns
                              last edited by

                              @yawns there used to be a ton of documentation on the API which for some reason is now offline. I found a list that was downloaded, here is the link

                              https://docs.google.com/viewer?a=v&pid=forums&srcid=MTI4MTUwMDQ0Mzg3NzE4MjExMDUBMTQyOTI2NzA2MDkyODAxMjI5MDABbmJnanZROTlFUUFKATAuMQEBdjI&authuser=0

                              yawnsY 1 Reply Last reply Reply Quote 1
                              • yawnsY Offline
                                yawns Moderator @ooom416354
                                last edited by

                                @ooom416354
                                Exactly what I was looking for. Thanks alot!

                                ooom416354O 2 Replies Last reply Reply Quote 0
                                • ooom416354O Offline
                                  ooom416354 @yawns
                                  last edited by

                                  @yawns no problem, I am still trying to find working link where this can be pulled, although there won’t be any new stations anytime soon.

                                  1 Reply Last reply Reply Quote 0
                                  • ooom416354O Offline
                                    ooom416354 @yawns
                                    last edited by

                                    @yawns Here’s all of the feeds, the site is down but I have the links:

                                    Full Station Listing with details:
                                    https://traintime.lirr.org/api/Stations-All

                                    Schedules based on Starting Station input (startsta=) and Ending Station input (endsta=) along with date/time (can be future dated)

                                    https://traintime.lirr.org/api/TrainTime?startsta=CLP&endsta=NYK&year=2017&month=02&day=04&hour=05&minute=00&datoggle=d

                                    Actual Train Schedules closest to the current time (passing in the 3 letter station code after loc=). This is different from the other link that I used for the JS file as it doesn’t show the ETA of the train.

                                    https://traintime.lirr.org/api/Departure?api_key=&loc=

                                    1 Reply Last reply Reply Quote 1
                                    • ooom416354O Offline
                                      ooom416354
                                      last edited by

                                      @yawns Hey I saw on git, MMM-MTA, not sure if that is all working or not though. Still working on configuring some stuff on my end but wanted to see if that was usable?

                                      yawnsY 1 Reply Last reply Reply Quote 0
                                      • yawnsY Offline
                                        yawns Moderator @ooom416354
                                        last edited by

                                        @ooom416354
                                        Hi, right that is the module I was working on. Over the last days I was completely busy doing cable stuff in my house and the weekend was blocked with dog training annual tax declaration.
                                        I try to complete it today or tomorrow.

                                        ooom416354O 1 Reply Last reply Reply Quote 0
                                        • ooom416354O Offline
                                          ooom416354 @yawns
                                          last edited by

                                          @yawns that’s amazing, thanks! I was going to start using it to try to teach myself by comparing the two. Thank you again!

                                          1 Reply Last reply Reply Quote 0

                                          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                          With your input, this post could be even better 💗

                                          Register Login
                                          • 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