Read the statement by Michael Teeuw here.
Not updating at midnight...
-
https://docs.magicmirror.builders/development/core-module-file.html

you could have done all the initial event calculating in one function
used interval for the midnights (as it’s a fixed number)
-
@BKeyport MODULE_DOM_CREATED means YOUR getDom()/getTemplateData() has been called
-
@sdetweil yeah, doing it that way just throws headers with “Undefined” until it triggers. I’m not gonna go down that rabbit hole. It seems to work as is, so I’m gonna release for now.
-
@BKeyport said in Not updating at midnight...:
start: function () {
function scheduleMidnightUpdate() {
const now = new Date();
const nextMidnight = new Date(now);// Set the time to midnight nextMidnight.setHours(24, 0, 0, 0); // Calculate the time remaining until the next midnight const timeUntilMidnight = nextMidnight - now; // Schedule the updateDom method to be called at midnight setTimeout(() => { this.updateDom(); // Reschedule the update for the next midnight scheduleMidnightUpdate.call(this); }, timeUntilMidnight); }},
I would do it like this , much more straight forward
function scheduleMidnightUpdate() { const now = new Date(); const nextMidnight = new Date(now); // Set the time to midnight nextMidnight.setHours(24, 0, 0, 0); // Calculate the time remaining until the next midnight const timeUntilMidnight = nextMidnight - now; // Schedule the updateDom method to be called at midnight setTimeout(() => { // trigger first update on next midnight change this.updateDom(); // start Recurring midnight change setInterval(()=>{ this.updateDom() }, 24*60*60*1000 ) // 24 hours * 60 minutes * 60 seconds * 1000 milliseconds (1 day elapsed in ms) setInterval delay }, timeUntilMidnight); // setTimeout delay } },then the system triggers every midnight… not your code
-
S sdetweil has marked this topic as solved on
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