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.

    Delay loading of one instance of a module and not another

    Scheduled Pinned Locked Moved Solved Troubleshooting
    7 Posts 2 Posters 924 Views 2 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.
    • D Offline
      DDE12
      last edited by

      I am trying to use two instances of https://github.com/philking98/MMM-horoscope to display the horoscope for Gemini and Sagittarius. I get the different signs displayed but the Gemini horoscope is duplicated under Sagittarius. I tried adding a delay but both of the instances appear to load at the same time. Is there a trick to slow one of them down so that hopefully it will pull the correct data? Thank you for taking a look at this.

      { // MMM-horoscope Gemini
              module: 'MMM-horoscope',
      	position: 'top_right',  
      	config: {
      		initialLoadDelay: 5000,
      		sign: 'gemini', // Zodiac sign
      		useTextIcon: false
      	}
      },
      { // MMM-horoscope Sagittarius
      	module: 'MMM-horoscope',
      	position: 'top_right', 
      	config: {
      		sign: 'sagittarius', // Zodiac sign
      		useTextIcon: false
      	}
      },
      

      Horoscope output.PNG

      S 1 Reply Last reply Reply Quote 0
      • D Offline
        DDE12 @sdetweil
        last edited by

        @sdetweil Seems to be working great! Thank you very much for taking the time to make this a multi-instance module! Also great that you eliminated the need for npm install node-fetch@2. Even though I don’t know very much about java script, I understand it much better than these horoscopes :grinning_squinting_face:

        1 Reply Last reply Reply Quote 1
        • S Offline
          sdetweil @DDE12
          last edited by sdetweil

          @DDE12 this modules doesn’t support multiple instances…

          to fix this the modulename.js needs to send some unique id with its request to the node_helper. we typically user this.identifier

          then the node_helper sends this value back as part of the data

          and then the modulenane.js checks if the returned value matches. because the sendSocketNotification from the node helper is a broadcast to all instances at the same time.

          I just fixed my pythonPrint module for this very problem

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • D Offline
            DDE12
            last edited by DDE12

            Thank you for the advice. I looked at your module and some others that allow for multiple instances but could not get it to work. I looked at some of the requests for multiple instances in the original (https://github.com/morozgrafix/MMM-horoscope) and the author commented that it would require rebuilding the entire module.
            As a work around, I cloned a second MMM-horoscope module and renamed the folder to MMM-horoscope2. Then renamed MMM-horoscope.js and MMM-horoscope.css to MMM-horoscope2.js and MMM-horoscope2.css. Then renamed all the .MMM-horoscope in the css to .MMM-horoscope2. Finally, I ran npm install in MMM-horoscope2 folder followed by npm install node-fetch@2.

            S 3 Replies Last reply Reply Quote 0
            • S Offline
              sdetweil @DDE12
              last edited by

              @DDE12 that’s the second approach

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @DDE12
                last edited by sdetweil

                @DDE12 use my fork, which supports multiple instances

                https://github.com/sdetweil/MMM-horoscope

                to test, rename the old module folder to some other name

                git clone and npm install for my module

                change the module name of your additional instances to the same as the 1st (now my module)

                if it fails, just rename my module folder out of the way,
                put back the other module folder
                and restore the module names in config.js

                it was a tiny change, so I think it will work

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • S Offline
                  sdetweil @DDE12
                  last edited by

                  @DDE12 I just added another update in case this module is used on a nodejs version below 18 to load a lib to support fetch

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  D 1 Reply Last reply Reply Quote 0
                  • D Offline
                    DDE12 @sdetweil
                    last edited by

                    @sdetweil Seems to be working great! Thank you very much for taking the time to make this a multi-instance module! Also great that you eliminated the need for npm install node-fetch@2. Even though I don’t know very much about java script, I understand it much better than these horoscopes :grinning_squinting_face:

                    1 Reply Last reply Reply Quote 1
                    • 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