Read the statement by Michael Teeuw here.
My module stops MMM-Pages working
-
@Scott-M not quite…
i avoid this state setting (this.loaded) by always waiting til ALL_MODULES_STARTED
before asking my helper to work, then I KNOW its good on socketNotificationReceived to use updateDomnotificationReceived: function(notification, payload, sender) { // once everybody is loaded up if(notification==="ALL_MODULES_STARTED"){ // send our config to our node_helper this.sendSocketNotification("CONFIG",this.config) }note: you CAN still get getDom() called BEFORE your socketNotification has been called by your node_helper sending data
so you need to check for data and return an empty DIV… (getDom MUST return SOMETHING) -
@sdetweil
I think I understand, am I getting closer with something like this:Module.register("MMM-TravelLine", { start() { this.timesReturned = []; }, notificationReceived(notification, payload, sender) { if (notification === "ALL_MODULES_STARTED") { console.log("All modules started; fetching routes now"); this.sendSocketNotification("FETCH_ROUTES", { username: this.config.username, password: this.config.password, apiBase: this.config.apiBase, stopIDs: this.config.stopIDs, timestamp: new Date().toISOString() }); // Schedule refresh setInterval(() => { this.sendSocketNotification("FETCH_ROUTES", { username: this.config.username, password: this.config.password, apiBase: this.config.apiBase, stopIDs: this.config.stopIDs, timestamp: new Date().toISOString() }); }, this.config.updateFrequency * 60 * 1000); } }, socketNotificationReceived(notification, payload) { if (notification === "UPDATED_ROUTES") { this.timesReturned = payload; this.updateDom(); } }, getDom() { const container = document.createElement("div"); container.className = "travelline-container"; if (!Array.isArray(this.timesReturned) || this.timesReturned.length === 0) { container.innerHTML = "<div class='no-data'>Loading bus times…</div>"; return container; } // ...builds table etc....... return container; } });Again, I have lost my remote conection to the PI so I can’t try it until tomorrow!
-
@Scott-M said in My module stops MMM-Pages working:
yes, looks good…
container.className = “travelline-container”;
you don’t have to set a class on the wrapper/container,
as MagicMirror has set your module name as a class on the module entryopen the developers window, and examine the html layout for a module in the elements tab
see the second link in my signature below -
@sdetweil Great, will hopefully get my mirror on the wall next week!#
-
@Scott-M awesome!
