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.

    mergeConfig() function

    Scheduled Pinned Locked Moved Development
    11 Posts 2 Posters 1.8k 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.
    • ? Offline
      A Former User
      last edited by A Former User

      I will code a sample wait ;)

      LoOOooL, now this script is not needed :)
      now MM v2.12.0 have solve this issue :)
      but still in v2.11.x

      I understand why you say i don't understand

      I see this at now, pfff i don’t read ChangeLog lol

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

        @Bugsounet also, _loadash lib is previously loaded, and loadash.merge does the deep merge, while Object.Assign does not.

        and it only matters for modules with big deep config structures. like GA

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        1 Reply Last reply Reply Quote 0
        • ? Offline
          A Former User
          last edited by

          it’s new because in v2.11.x, I have to use mergeConfig()

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

            @Bugsounet lodash.merge loaded before 2.12.

            just saying it’s easy, if u need to do this, without another script

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • ? Offline
              A Former User
              last edited by

              So I do some another test and not worked without configMerge()

              Module name : MMM-Freebox (in dev for new version)
              in MMM-Freebox.js:

                defaults: {
                  updateDelay:  5 * 1000,
                  token: "",
                  activeOnly: false,
                  showIcon: true,
                  showButton: true,
                  showBandWidth: true,
                  showRate: true,
                  showClient: true,
                  showClientRate: true,
                  showClientCnxType: true,
                  showFreePlayer: true,
                  showMissedCall: true,
                  showVPNUsers: true,
                  maxMissed: 3,
                  showIP: true,
                  showPing: true,
                  pingAdress: "google.fr",
                  textWidth: 250,
                  excludeMac: [],
                  sortBy: null,
                  debug: false,
                  verbose: false,
                  dev: false,
                  debitText: "Débit total utilisé : ",
                  player : {
                    showPlayerInfo: false,
                    // depuis le firmware 4.2.3, problemes d'affichage des logos
                    // essayez avec les ips :  "192.168.0.254" (l'ip du freebox server)
                    //                         "mafreebox.free.fr" ou le resultat de l'ip de mafreebox.free.fr
                    //                         "212.27.38.253" l'ip de mafreebox.free.fr (a voir si cela fonctionne pour vous)
                    ServerIP: "212.27.38.253",
                    UseEPGDayURL: true,
                    EPGDelay: 2* 60 *60 *1000
                  }
                },
              

              I try to merge config with MMM-Freebox.js :

                start: function () {
                  this.config = Object.assign({}, this.defaults, this.config)
              

              I send config to node_helper.js with:

                notificationReceived: function (notification, payload) {
                  switch(notification) {
                    case "DOM_OBJECTS_CREATED":
                      this.sendSocketNotification("INIT", this.config)
                      break
                  }
                },
              

              module configuration in config.js:

              {
                module: "MMM-Freebox",
                disabled: false,
                header: "INFO Freebox",
                position: "top_center",
                config: {
                  token: "xxxx",
                  updateDelay:  5 * 1000,
                  activeOnly: false,
                  sortBy: "type",
                  showButton: true,
                  debug: true,
                  //dev: true,
                  //verbose: true,
                  showVPNUsers: true,
                  textWidth: 250,
                  player: {
                    showPlayerInfo: true
                  }
                }
              },
              

              result in node_helper.js:

              [2020-08-10 16:53:52.705] [LOG]    {
                updateDelay: 5000,
                token: 'xxxx',
                activeOnly: false,
                showIcon: true,
                showButton: true,
                showBandWidth: true,
                showRate: true,
                showClient: true,
                showClientRate: true,
                showClientCnxType: true,
                showFreePlayer: true,
                showMissedCall: true,
                showVPNUsers: true,
                maxMissed: 3,
                showIP: true,
                showPing: true,
                pingAdress: 'google.fr',
                textWidth: 250,
                excludeMac: [],
                sortBy: 'type',
                debug: true,
                verbose: false,
                dev: false,
                debitText: 'Débit total utilisé : ',
                player: { showPlayerInfo: true }
              }
              

              so config is not merged !

              now … Let’s try with configMerge() with SAME configuration
              just modify :

                start: function () {
                  this.config = configMerge({}, this.defaults, this.config)
              

              result in node_helper.js:

              [2020-08-10 17:08:14.984] [LOG]    {
                updateDelay: 5000,
                token: 'xxxx',
                activeOnly: false,
                showIcon: true,
                showButton: true,
                showBandWidth: true,
                showRate: true,
                showClient: true,
                showClientRate: true,
                showClientCnxType: true,
                showFreePlayer: true,
                showMissedCall: true,
                showVPNUsers: true,
                maxMissed: 3,
                showIP: true,
                showPing: true,
                pingAdress: 'google.fr',
                textWidth: 250,
                excludeMac: [],
                sortBy: 'type',
                debug: true,
                verbose: false,
                dev: false,
                debitText: 'Débit total utilisé : ',
                player: {
                  showPlayerInfo: true,
                  ServerIP: '212.27.38.253',
                  UseEPGDayURL: true,
                  EPGDelay: 7200000
                }
              }
              

              You can’t see that player: {} value is now set and merged with default value

              @MichMich :

              in MM core js/module.js

              	/* setConfig(config)
              	 * Set the module config and combine it with the module defaults.
              	 *
              	 * argument config object - Module config.
              	 */
              	setConfig: function (config) {
              		this.config = Object.assign({}, this.defaults, config);
              	},
              

              Can I send you a patch with configMerge() script for solve this developer issue (It take head !) ?

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

                @Bugsounet open a PR, describe the problem, and your solution

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • ? Offline
                  A Former User
                  last edited by

                  sure, i just open it

                  1 Reply Last reply Reply Quote 1
                  • ? Offline
                    A Former User
                    last edited by

                    Ok, so, after one month

                    1. No news on this topic (I have mentionned @MichMich but …)
                    2. I have open an issue, no news
                    3. i have make a PR, euh no news too ??

                    So i decide I close Issue and PR
                    it’s not a problem for me… i use my own tools :)

                    In this forum,
                    There are not many developers left …
                    So avoid listening to them, you would have even less :)
                    I don’t know what you are looking for :)

                    For the moment, you have one motivated!
                    This is not likely to continue for long …

                    @bugsounet for @MichMich

                    1 Reply Last reply Reply Quote 0
                    • ? Offline
                      A Former User
                      last edited by

                      Waiting… and Waiting …

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