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.

    multiple module instances overwrites itself values

    Scheduled Pinned Locked Moved Unsolved Development
    13 Posts 7 Posters 9.9k Views 9 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
      BenRoe Module Developer
      last edited by

      Hello,
      i am working on a module for FHEM. The module can show data like temperature from FHEM devices. It is working, but if i add two instances of the module to the config.js it overwrites the dom values.

          {
            module: 'MMM-FHEM',
            position: 'bottom_bar',
            config: {
              host: '192.168.178.28',
              port: '8083',
              deviceNames: [
                            'LaCr.Thermo01',
                            'LaCr.Thermo02',
                            'LaCr.Thermo03',
                           ],
              deviceReadings: [
                                { name: 'temperature', icon: 'wi wi-thermometer', suffix: '°' },
                                { name: 'humidity', icon: 'wi wi-humidity', suffix: '%' },
                              ],
            },
          },
          {
            module: 'MMM-FHEM',
            position: 'top_right',
            header: 'top_right',
            config: {
              host: '192.168.178.28',
              port: '8083',
              deviceNames: [
                            'LaCr.Thermo03',
                            'LaCr.Thermo04',
                            'LaCr.Thermo05',
                           ],
              deviceReadings: [
                                { name: 'temperature', icon: 'wi wi-thermometer', suffix: '°' },
                                { name: 'humidity', icon: 'wi wi-humidity', suffix: '%' },
                              ],
            },
          },
      

      Right values should different from the bottom one.
      0_1474756392729_Bildschirmfoto 2016-09-25 um 00.32.15.png

      Any idea why? You can find the code here https://github.com/BenRoe/MMM-FHEM

      1 Reply Last reply Reply Quote 1
      • B Offline
        BenRoe Module Developer
        last edited by

        Ok other question.
        If i setup a module twice in the config, do they share the variables from the code?

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

          Any news here?

          B 1 Reply Last reply Reply Quote 0
          • B Offline
            BenRoe Module Developer @DazDavid
            last edited by

            @DazDavid nope

            1 Reply Last reply Reply Quote 0
            • C Offline
              chrisyy
              last edited by

              Would it work if u give them names like MMM-FHEM1 and MMM-FHEM2?

              Cause if u add two instances with the same name in the config i can imagine, that he will read the first value and overwrites them in the second instance. Like

              var variable = 1;
              var variable = 2;

              Output would be 2.

              1 Reply Last reply Reply Quote 0
              • B Offline
                bobbob601
                last edited by

                This post is deleted!
                B 1 Reply Last reply Reply Quote 3
                • B Offline
                  BenRoe Module Developer @bobbob601
                  last edited by

                  @bobbob601 thx for the answer. Do you have a example how to write a module with multi-instace support?

                  RedNaxR 1 Reply Last reply Reply Quote 0
                  • RedNaxR Offline
                    RedNax Module Developer @BenRoe
                    last edited by RedNax

                    @BenRoe

                    Having the same problem with my module… A theoretical solution could be to make node_helper multi instance aware by appending some identifier to the notification unique to the instance: ie GET_WEATHER_001… The helper triggers on GET_WEATHER and builds an array with the different notifications and payloads. It then periodically runs through the array getting the appropriate requests and sending out notifications like WEATHER_001 with the specific payload.

                    Haven’t built it yet though…

                    1 Reply Last reply Reply Quote 0
                    • B Offline
                      bobbob601
                      last edited by

                      This post is deleted!
                      T 1 Reply Last reply Reply Quote 0
                      • T Offline
                        trgraglia @bobbob601
                        last edited by

                        @bobbob601 I got it working by passing a unique ID to the node helper and passing it back from the node helper.

                        https://github.com/trgraglia/MMM-MVG-LocalTransport

                        Hope this helps.

                        http://www.anthonygraglia.com/

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