• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Reloading config defaults or module

Scheduled Pinned Locked Moved Development
10 Posts 2 Posters 1.1k Views 1 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 Jul 22, 2020, 7:10 PM

    This post is deleted!
    S 1 Reply Last reply Jul 22, 2020, 7:11 PM Reply Quote 0
    • S Offline
      sdetweil @Guest
      last edited by Jul 22, 2020, 7:11 PM

      @hango what do u mean reload?

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      S 1 Reply Last reply Jul 22, 2020, 7:14 PM Reply Quote 0
      • S Offline
        sdetweil @sdetweil
        last edited by sdetweil Jul 22, 2020, 7:17 PM Jul 22, 2020, 7:14 PM

        @sdetweil the mm startup takes what you have in config for a module and merges it with the defaults section in the module_name.js, with the config replacing the same named default value.

        so, if u make the config section for a module
        config:{}
        then u will get all the module defaults the next time the mirror is started.

        because of this design, there is never any reason to edit the module source code, unless you are extending he functionality or correcting a coding problem

        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 A Former User Jul 22, 2020, 7:21 PM Jul 22, 2020, 7:17 PM

          This post is deleted!
          S 1 Reply Last reply Jul 22, 2020, 7:24 PM Reply Quote 0
          • S Offline
            sdetweil @Guest
            last edited by sdetweil Jul 22, 2020, 7:25 PM Jul 22, 2020, 7:24 PM

            @hango because u coded the value in the array, it is calculated at the time the array is built, NOT at the time it is USED

            so, start the mirror at 2pm, and the value will be calculated as of 2pm.

            what u will want is a function that returns a value , calculated by the function.

            I don’t think the default compliments module can do that, but havent read the code much beyond fixing the embedded \n problem last year sometime.

            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 A Former User Jul 22, 2020, 7:50 PM Jul 22, 2020, 7:31 PM

              This post is deleted!
              S 1 Reply Last reply Jul 22, 2020, 8:18 PM Reply Quote 0
              • S Offline
                sdetweil @Guest
                last edited by Jul 22, 2020, 8:18 PM

                @hango you will have to write code to allow a function instead of a string, then detect to function and call it to get the string to display

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                ? 1 Reply Last reply Jul 22, 2020, 8:20 PM Reply Quote 0
                • ? Offline
                  A Former User @sdetweil
                  last edited by A Former User Jul 22, 2020, 8:39 PM Jul 22, 2020, 8:20 PM

                  This post is deleted!
                  S 1 Reply Last reply Jul 22, 2020, 10:20 PM Reply Quote 0
                  • S Offline
                    sdetweil @Guest
                    last edited by Jul 22, 2020, 10:20 PM

                    @hango the code was less than i thought
                    replace this (last line of randomCompliment)

                            return   compliments[index] || '';
                    

                    with this

                    		var f = compliments[index];
                    		if ( typeof f == 'function') f= f()
                    		return f || "";
                    

                    a compliment config entry would look like this

                      module: "compliments",
                      config: { 
                          compliments : {
                               'anytime': [ function(){return "this is a  test "+ moment().format('MM DD HH:MM:SS')}
                                                      ]
                           }
                    }
                    

                    all of the things can be functions, or any combo down to just 1 entry as a function.
                    the function must return a string

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    ? 1 Reply Last reply Jul 23, 2020, 6:15 AM Reply Quote 0
                    • ? Offline
                      A Former User @sdetweil
                      last edited by Jul 23, 2020, 6:15 AM

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • 1 / 1
                      1 / 1
                      • First post
                        1/10
                        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