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.

    Need help - New programmer

    Scheduled Pinned Locked Moved General Discussion
    23 Posts 5 Posters 4.8k Views 5 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.
    • A Offline
      ashishtank Module Developer
      last edited by

      @smart_user Where you are stuck ? check the default modules code, you will need to configure a timer to repeat the task every 1 hour (should be configurable). and in that task you should display message on screen.

      Check window.timeout and window.setInterval function of javascript.

      S 1 Reply Last reply Reply Quote 0
      • S Do not disturb
        sdetweil @smart_user
        last edited by

        @smart_user you could use my sample module which puts up a configured message every few minutes. Change the message and the time…

        https://github.com/sdetweil/SampleModule

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        S 1 Reply Last reply Reply Quote 1
        • S Offline
          smart_user @ashishtank
          last edited by

          @ashishtank Yes I will look into it. Thank you so much for the instant reply. Appreciate it a lot

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

            @sdetweil Thank you so much! I will use this module and let you know how it goes!

            S 1 Reply Last reply Reply Quote 0
            • S Do not disturb
              sdetweil @smart_user
              last edited by

              @smart_user ok. Timer is in the node_helper.
              It is a one time timer, setTimer, vs repeating, setInterval.

              Doesn’t need to be in the node_helper, but did that to show the structure and communication between the parts

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • S Offline
                smart_user
                last edited by

                @sdetweil It still isn’t working. I had configured for the alert to show up in 10 seconds but it didn’t

                S 1 Reply Last reply Reply Quote 0
                • S Do not disturb
                  sdetweil @smart_user
                  last edited by sdetweil

                  @smart_user you changed the 15000 in node_helper to 10000, right?

                  And u had a position: set in config.js, right?

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • S Offline
                    smart_user
                    last edited by

                    @sdetweil Yes

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      smart_user
                      last edited by

                      @sdetweil Is it possible for you to send me a picture of the .js file so I can double check?

                      S 1 Reply Last reply Reply Quote 0
                      • S Do not disturb
                        sdetweil @smart_user
                        last edited by

                        @smart_user u can look on the github site

                        View code. Then click on file.

                        If you used git clone, then u can do

                        git diff node_helper.js
                        to see the differences

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        1 Reply Last reply Reply Quote 0
                        • S Offline
                          smart_user
                          last edited by

                          @sdetweil Hello. I did and still am not receiving any alert on the screen

                          S 1 Reply Last reply Reply Quote 0
                          • S Do not disturb
                            sdetweil @smart_user
                            last edited by

                            @smart_user show me the config block. Minimum is this. MUST have a position

                            {
                                 module:"SampleModule",
                                 position:"middle",
                             },
                            

                            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

                              euh … position needed ONLY if you have to show something on the mirror (getDom).
                              If you have nothing to show THEN position is not needed

                              Note: verified in my lasted module (position is not needed because no visual)

                              S 1 Reply Last reply Reply Quote 0
                              • S Do not disturb
                                sdetweil @Guest
                                last edited by

                                @Bugsounet yes, my sample module DOES want to display something

                                Sam

                                How to add modules

                                learning how to use browser developers window for css changes

                                1 Reply Last reply Reply Quote 0
                                • S Offline
                                  smart_user
                                  last edited by

                                  @sdetweil Yes! I missed adding the position to the config file. Just have another clarification. Can these messages show up for a few seconds then disappear and then appear again after 30 minutes? If so, how do I do that?

                                  S 1 Reply Last reply Reply Quote 0
                                  • S Do not disturb
                                    sdetweil @smart_user
                                    last edited by sdetweil

                                    @smart_user sure. When u want the message to go away, set the string to empty, or not create any content in getDom()…

                                    U would start a timer after u display the text, and the call updateDom() in the timer routine.

                                    Wait, display. Wait. Remove output
                                    Repeat

                                    Sam

                                    How to add modules

                                    learning how to use browser developers window for css changes

                                    1 Reply Last reply Reply Quote 0
                                    • I Offline
                                      innovation
                                      last edited by

                                      @sdetweil Hello, I am facing the same problem - and I want the same feature @smart_user mentioned. But I am sorry, I didn’t get the timer part. Which string are you talking about? and where will I add the updateDom()? Please help

                                      S 2 Replies Last reply Reply Quote 0
                                      • S Do not disturb
                                        sdetweil @innovation
                                        last edited by

                                        @innovation i have my grandson for a few hours will get back to you

                                        Sam

                                        How to add modules

                                        learning how to use browser developers window for css changes

                                        1 Reply Last reply Reply Quote 0
                                        • I Offline
                                          innovation
                                          last edited by

                                          sure @sdetweil, no problem!

                                          1 Reply Last reply Reply Quote 0
                                          • S Do not disturb
                                            sdetweil @innovation
                                            last edited by sdetweil

                                            @innovation the ‘string’ is the value used in the getDom() function to create the html content

                                            somestring:“this is just a test string”,
                                            counter: 0,

                                            getDom(){
                                               var wrapper=createElement("div")
                                               wrapper.innerText=this.somestring
                                               return wrapper;
                                            }
                                            

                                            there is no stopping the module, it MUST always be running… so, if u want to change the string,
                                            you can start a timer, and when the timer expires, call a routine that does the work.

                                            timerRoutine: function(){
                                                 this.somestring="some other string"
                                            }
                                            

                                            but how does MM know u changed the value?
                                            u tell MM there is new content…

                                            timerRoutine: function(){
                                                 this.somestring="some other string "+ this.counter++;
                                                 this.updateDom(time_to_delay_in_ms, 0 = immediately)
                                            }
                                            

                                            now we need to start a timer… lets say, 15 seconds after we do it in getDom, lets change the text

                                            getDom(){
                                               var wrapper=createElement("div')
                                               wrapper.innerText=this.somestring  // use the value of the somestring variable to display
                                              setTimeout(this.timerRoutine, 15000)   // call the timerRoutine in 15000 milliseconds
                                               return wrapper;
                                               // after here , MM will put the html tree defined in wrapper,
                                               // in the 'position' the module  defined in config.js
                                            }
                                            

                                            another way is to use the repeating timer, instead of the single event version

                                            start: {
                                                // now the timerRoutine will be called every 15 seconds, forever
                                                // it will change the string, and then inform MM to call to get new content
                                                setInterval(this.timerRoutine,15000) //  start a repeating timer  every 15 seconds
                                            },
                                            
                                            getDom(){
                                               var wrapper=createElement("div')
                                               wrapper.innerText=this.somestring  // use the value of the somestring variable to display
                                               return wrapper;
                                            }
                                            

                                            you can do this same updateDom() call after receiving a message back from your node helper with new content.
                                            (my sample module does this)

                                            Sam

                                            How to add modules

                                            learning how to use browser developers window for css changes

                                            1 Reply Last reply Reply Quote 2

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 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