• 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.

Module Refresh Time

Scheduled Pinned Locked Moved Forum
11 Posts 3 Posters 2.7k 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.
  • M Offline
    mumblebaj Module Developer
    last edited by Apr 19, 2022, 4:59 PM

    I have a quick question. I am wondering if the following is possible. In our modules we set a refresh Interval, say 1 hour 2 hours or 24 hours etc. Is it possible to set it to a specific time of day other than having to start the mirror at that specific time of day?

    So, currently I have a module that refreshes every 24 hours but to get it to refresh at the specific time of day that I want it to, I had to start the mirror at that specific time in order for the module to only refresh at that specific time the next day. Instead of having to do that, is it possible to set a module to refresh at a specific time?

    Was just wondering if it is possible and how if it is?

    Check out my modules at: https://github.com/mumblebaj?tab=repositories

    S C 2 Replies Last reply Apr 19, 2022, 6:01 PM Reply Quote 0
    • S Away
      sdetweil @mumblebaj
      last edited by Apr 19, 2022, 6:01 PM

      @mumblebaj we you can calculate the delta between now and that specific time of day, as the initial delay, and then shift to 24 hours for the next from the new ‘now’

      I do this in my COVID module, as the data won’t be available before 8 am every day… get the data, reset to wait til 8am, then try to get the data… repeat… sometimes it’s available at 8:05, sometimes not til after 11am

      milliseconds is just a number

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      M 1 Reply Last reply Apr 19, 2022, 6:14 PM Reply Quote 0
      • M Offline
        mumblebaj Module Developer @sdetweil
        last edited by Apr 19, 2022, 6:14 PM

        @sdetweil Thanks for that Sam. Let me have a look at what you set on your module.

        So setting a specific time like one would in say crontab is not possible.

        Check out my modules at: https://github.com/mumblebaj?tab=repositories

        S 1 Reply Last reply Apr 19, 2022, 6:51 PM Reply Quote 0
        • S Away
          sdetweil @mumblebaj
          last edited by Apr 19, 2022, 6:51 PM

          @mumblebaj correct. setTimeout() and setInterval() take milliseconds from now

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • C Offline
            cowboysdude Module Developer @mumblebaj
            last edited by cowboysdude Apr 21, 2022, 12:08 AM Apr 21, 2022, 12:08 AM

            @mumblebaj in some modules at the top of the main js file you may see this ->

            updateInterval: 50 * 60 * 1000,
            

            Or you could add it to a module if need be.

            S 1 Reply Last reply Apr 21, 2022, 12:48 AM Reply Quote 0
            • S Away
              sdetweil @cowboysdude
              last edited by sdetweil Apr 21, 2022, 1:37 PM Apr 21, 2022, 12:48 AM

              @cowboysdude but he wanted to wake up at a specific time of day

              so,
              create a date object with the target date and time,
              extract its milliseconds,
              subtract now ms from that= wait_ms,
              setTimeout(fn, wait_ms)

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              C 1 Reply Last reply Apr 22, 2022, 12:44 AM Reply Quote 1
              • C Offline
                cowboysdude Module Developer @sdetweil
                last edited by Apr 22, 2022, 12:44 AM

                @sdetweil Yes you are right on both accounts :)

                M 1 Reply Last reply Apr 22, 2022, 3:17 PM Reply Quote 0
                • M Offline
                  mumblebaj Module Developer @cowboysdude
                  last edited by Apr 22, 2022, 3:17 PM

                  @cowboysdude I love it when you old timers get into it… I am looking at the @sdetweil suggestions. Thought there might have been an easier way.

                  Check out my modules at: https://github.com/mumblebaj?tab=repositories

                  S 1 Reply Last reply Apr 22, 2022, 3:23 PM Reply Quote 0
                  • S Away
                    sdetweil @mumblebaj
                    last edited by sdetweil Apr 22, 2022, 3:28 PM Apr 22, 2022, 3:23 PM

                    @mumblebaj u can of course add ANOTHER library, only accessable from node_helper…

                    https://www.npmjs.com/package/node-cron

                    seems a lot of work for one little routine… with 1 line of code

                    and you can use moment too

                    https://stackoverflow.com/questions/36158193/javascript-set-a-new-date-to-tomorrow-8am

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    M 1 Reply Last reply Apr 22, 2022, 3:26 PM Reply Quote 0
                    • M Offline
                      mumblebaj Module Developer @sdetweil
                      last edited by Apr 22, 2022, 3:26 PM

                      @sdetweil Yep, i will look at your suggestion. Keeps it nice and tidy

                      Check out my modules at: https://github.com/mumblebaj?tab=repositories

                      S 1 Reply Last reply Apr 22, 2022, 3:29 PM Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        7/11
                        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