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.

    global variables in config.js

    Scheduled Pinned Locked Moved Unsolved Feature Requests
    14 Posts 3 Posters 3.1k 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.
    • S Offline
      sdetweil @vbloke
      last edited by

      @vbloke you need to update the CHANGELOG.md file

      and maybe some of the existing README.md for configuration

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      vblokeV 1 Reply Last reply Reply Quote 0
      • vblokeV Offline
        vbloke Module Developer @sdetweil
        last edited by

        @sdetweil Done!

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

          It might be just a stupid question. But how do you think this approach? it doesn’t need to make a PR. and doesn’t need to match/edit the option naming convention of each module.

          const global = {
            latitude: "51.1",
            language: "en",
            ...
          } 
          
          var config = {
            ...
            modules: [
              {
                 module: "MMM-Something",
                 config: {
                    latitude: global["latitude"],
                    language: global["language"],
                 },
              },
              {
                 module: "MMM-Otherthing",
                 config: {
                    deviceLatitude: global["latitude"],
                    lang: global["language"],
                 },
              },
            ]
          };
          
          
          
          S 1 Reply Last reply Reply Quote 0
          • S Offline
            sdetweil @Guest
            last edited by sdetweil

            @Sean said in global variables in config.js:

            const global = {
            latitude: “51.1”,
            language: “en”,
            …
            }

            that requires a PR if you want it there for EVERY module developer to leverage…
            else, you are back to what we have now… oh, no info available, i will have to collect it myself…

            if it was THERE , then one could just GET it… not even need in module config section…
            this is where module depends on version gets useful…

            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 @sdetweil
              last edited by A Former User

              @sdetweil said in global variables in config.js:

              that requires a PR if you want it there for EVERY module developer to leverage…
              else, you are back to what we have now… oh, no info available, i will have to collect it myself…

              No PR is needed. The user could just put the code in his config.js if he wants.

              I meant (I thought), it is better to be entrusted how to use it by User, not module Developer. My approach doesn’t need to change anything of current MM, but give some freedom to the user who wants to use common duplicated values in modules.

              @vbloke’s solution needs modules to be edited to support MM-level-global-values. For example, I should modify my MMM-AssistantMk2 to support global latitude and longitude of @vbloke’s solution.
              I doubt it really being worth it.

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

                @Sean @vbloke BUT, if the globals were defined (in the MM base),

                the YOUR way would become the normal , useful way…

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • vblokeV Offline
                  vbloke Module Developer
                  last edited by

                  As long as the information can be put in the top level and made available to modules without having to repeat common variables over and over again in individual module configs, I don’t mind how it’s done.

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

                    Don’t get me wrong. I don’t want to make any argument about this issue. I also believe the global level values be needed and useful really. However, I’m just saying about reality.

                    Anyway who decides which variables should be included as MM-level-default-global?
                    Maybe timeFormat and language might be the ones definitely. But those are already included. (By the way, timeFormat:24 is not so really useful to define complex time format of calendars or clocks. What 24 means? “23:45”? “23:45:01”? “23:45:01 pm”?)
                    Maybe profile-related-things and page-related-things could be ones also. (Personally, I wish profile to be supported on MM by default).
                    But others? what remains? As a module developer, if I want MM community to adopt my variable verbose: as a default global value, Should I make a PR for it? But if other developers never use/support that field either despite including, what is its worth?
                    Only that is just my worry.

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

                      @Sean i just made a change to fix problems with the older pi hardware… and while fixing that realized everyone that needs to run serveronly has to create the startup scripts themselves, and its all hard coded…

                      so, I added another variable to the config.js, serverOnly:

                      it will help some users…

                      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 @Guest
                        last edited by sdetweil

                        @Sean “24” means not am/pm, and it shows seconds ticking…

                        you have great ideas, and modules… share improvements to help everyone!..

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

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