<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MMM-MealViewer]]></title><description><![CDATA[<p dir="auto">I’m trying to develop a module to get today’s school lunch menu options from my kids’ school. The district uses a service provided by <a href="http://mealviewer.com" target="_blank" rel="noopener noreferrer nofollow ugc">mealviewer.com</a>. The API is available at <a href="https://api.mealviewer.com/api/v4/school/%5Bschoolname%5D/" target="_blank" rel="noopener noreferrer nofollow ugc">https://api.mealviewer.com/api/v4/school/[schoolname]/</a>[date range start MM-DD-YYYY]/[date range end MM-DD-YYYY]/. To keep it simple I’m only pulling the current day so the start and end date values are the same.</p>
<p dir="auto">Here’s an example: <a href="https://api.mealviewer.com/api/v4/school/ElmwoodElementary/02-15-2019/02-15-2019/" target="_blank" rel="noopener noreferrer nofollow ugc">https://api.mealviewer.com/api/v4/school/ElmwoodElementary/02-15-2019/02-15-2019/</a></p>
<p dir="auto">You can see that there is a TON of XML data returned. I’m only interested in the [CafeteriaLine] nodes and each of their respective [FoodItem] nodes and then the respective [Item_Type] and [Item_Name] for each [FoodItem].</p>
<p dir="auto">I’m able to send an HTTP request and get (some) data but, unfortunately, most of the nonsense is returned and I don’t see the menu information. It’s like a big chunk out of the middle of the XML data is missing, whether I dump it out to the log before or after parsing it to JSON.</p>
<p dir="auto">Any thoughts?</p>
]]></description><link>https://forum.magicmirror.builders/topic/9812/mmm-mealviewer</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 04:13:20 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/9812.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 16 Feb 2019 22:41:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 19:16:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> JSON is perfect:</p>
<p dir="auto"><img src="/assets/uploads/files/1576264518754-ff13b851-b585-43c2-a741-02e28faa83e9-image.png" alt="0_1576264519518_ff13b851-b585-43c2-a741-02e28faa83e9-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Thanks for the help so far!! Now I have my data I can play around with it.</p>
]]></description><link>https://forum.magicmirror.builders/post/65978</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65978</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 19:16:13 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 19:11:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> u should look at the data format</p>
<pre><code>getMTVM: function(url) {
               let self=this
		request(url, function(err, res, body) {
		        // if no error and server was happy
			if(err == null &amp;&amp; res.statusCode ==200){
			   console.log(body);
			   xml2js.parseString(body,function (err,result) {
			       let json_data = result // not needed but may make more clear
			       console.log(JSON.stringify(json_data))			   
			   });		   
			}
		});
	},
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/65976</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65976</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 19:11:03 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 19:10:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> Almost there I think ;-)</p>
<pre><code>Whoops! There was an uncaught exception...
TypeError: Cannot read property '0' of undefined
    at /home/pi/MagicMirror/modules/MMM-MyTVMovies/node_helper.js:28:47
    at Parser.&lt;anonymous&gt; (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/xml2js/lib/parser.js:306:18)
    at Parser.emit (events.js:182:13)
    at SAXParser.onclosetag (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/xml2js/lib/parser.js:264:26)
    at emit (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/sax/lib/sax.js:624:35)
    at emitNode (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/sax/lib/sax.js:629:5)
    at closeTag (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/sax/lib/sax.js:889:7)
    at SAXParser.write (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/sax/lib/sax.js:1436:13)
    at Parser.exports.Parser.Parser.parseString (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/xml2js/lib/parser.js:325:31)
    at Parser.parseString (/home/pi/MagicMirror/modules/MMM-MyTVMovies/node_modules/xml2js/lib/parser.js:5:59)
</code></pre>
<p dir="auto">Has this something to do with the json_data.film[0].titel ??<br />
Or is it something else?</p>
<p dir="auto">When I remove .film[0].titel I got:</p>
<pre><code>Text is [object Object]
200[object Object]
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/65975</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65975</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 19:10:57 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 19:01:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> yeh, tricky crap… they had a special runtime that supported that… sorry…<br />
have to use one of the libs…</p>
<p dir="auto">in your module folder do</p>
<pre><code>npm install xml2js
</code></pre>
<p dir="auto">then in your code</p>
<pre><code>const xml2js = require('xml2js');
</code></pre>
<p dir="auto">then</p>
<pre><code>getMTVM: function(url) {
               let self=this
		request(url, function(err, res, body) {
		        // if no error and server was happy
			if(err == null &amp;&amp; res.statusCode ==200){
			   console.log(body);
			   xml2js.parseString(body,function (err,result) {
			       let json_data = result // not needed but may make more clear
			       console.log("Text is " + json_data.film[0].titel)			   
			   });		   
			}
		});
	},
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/65973</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65973</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 19:01:56 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:51:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a>  Yeah! That part is working. Now I’ve an other error which has something to do with the xmlToJson function:</p>
<pre><code>Whoops! There was an uncaught exception...
TypeError: xml.hasChildNodes is not a function
</code></pre>
<p dir="auto">Any idea?</p>
]]></description><link>https://forum.magicmirror.builders/post/65972</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65972</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:44:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> ah the fun of ‘this’…</p>
<pre><code>	getMTVM: function(url) {
               let self=this
		request(url, function(err, res, body) {
		        // if no error and server was happy
			if(err == null &amp;&amp; res.statusCode ==200){
			   console.log(body);
			   var json_data = self.xmlToJson(body)
			   console.log("Text is " + json_data.film[0].titel)
			}
		});
	},
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/65971</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65971</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:44:30 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:38:35 GMT]]></title><description><![CDATA[<p dir="auto">Mmmm… not working yet…<br />
My current node_helper.js:</p>
<pre><code>const NodeHelper = require('node_helper');
const request = require('request');

module.exports = NodeHelper.create({

    start: function() {
        console.log("Starting node_helper for: " + this.name);
    },
	
	// Changes XML to JSON
	xmlToJson: function(xml) {
		
		// Create the return object
		var obj = {};

		if (xml.nodeType == 1) { // element
			// do attributes
			if (xml.attributes.length &gt; 0) {
			obj["@attributes"] = {};
				for (var j = 0; j &lt; xml.attributes.length; j++) {
					var attribute = xml.attributes.item(j);
					obj["@attributes"][attribute.nodeName] = attribute.nodeValue;
				}
			}
		} else if (xml.nodeType == 3) { // text
			obj = xml.nodeValue;
		}

		// do children
		if (xml.hasChildNodes()) {
			for(var i = 0; i &lt; xml.childNodes.length; i++) {
				var item = xml.childNodes.item(i);
				var nodeName = item.nodeName;
				if (typeof(obj[nodeName]) == "undefined") {
					obj[nodeName] = xmlToJson(item);
				} else {
					if (typeof(obj[nodeName].push) == "undefined") {
						var old = obj[nodeName];
						obj[nodeName] = [];
						obj[nodeName].push(old);
					}
					obj[nodeName].push(xmlToJson(item));
				}
			}
		}
		return obj;
	},
		
	
	getMTVM: function(url) {
		request(url, function(err, res, body) {
		// if no error and server was happy
			if(err == null &amp;&amp; res.statusCode ==200){
			console.log(body);
			var json_data = this.xmlToJson(body)
			console.log("Text is " + json_data.film[0].titel)
			}
		});
	},


    socketNotificationReceived: function(notification, payload) {
        if (notification === 'GET_MTVM') {
            this.getMTVM(payload);
        }
    }
});

</code></pre>
<p dir="auto">In the dev console I get an error:</p>
<pre><code>Whoops! There was an uncaught exception...
TypeError: this.xmlToJson is not a function
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/65970</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65970</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:38:35 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:17:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a>  and the number of films in the array would be</p>
<p dir="auto">json_data.film.length</p>
<p dir="auto">using the developers window you can put a code stop on the line after the xml2json<br />
and then u can explore the conversion…</p>
<p dir="auto">you can also use console.log(JSON.stringify(some_object)) and it will dump the structure in json format</p>
]]></description><link>https://forum.magicmirror.builders/post/65967</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65967</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:17:56 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:14:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> correct (json_data is the name of the output variable, note underscore, not dot, using dot means ‘go into’)  … if you use one of the module add ons… not the code shown…</p>
]]></description><link>https://forum.magicmirror.builders/post/65966</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65966</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:14:16 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 18:11:25 GMT]]></title><description><![CDATA[<p dir="auto">So in my case the URL produces:</p>
<p dir="auto"><img src="/assets/uploads/files/1576260495423-7fa5a24c-528a-4697-9557-2a9058df2860-image.png" alt="0_1576260496007_7fa5a24c-528a-4697-9557-2a9058df2860-image.png" class=" img-fluid img-markdown" /> image url)</p>
<p dir="auto">json_data.SD[0].SPEED@attributes.TEXT will be:</p>
<pre><code>json.data.film[0].titel    --&gt; 'Bellicher: Cel'
</code></pre>
<p dir="auto">Correct?</p>
]]></description><link>https://forum.magicmirror.builders/post/65965</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65965</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 18:11:25 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 17:57:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> the url bring back the data with request</p>
<pre><code>request(url, function(err, res, body) {
    // if no error and server was happy
    if(err == null &amp;&amp; res.statusCode ==200){
    console.log(body);
    var json_data=this.xmlToJson(body)
    console.log("Speed[0] text is "+json_data.SD[0].SPEED.@attributes.TEXT)
}
});
</code></pre>
<p dir="auto">when the server responds, the function is called and passed the data, body)<br />
and then u would convert it from xml to json . using the last code</p>
<p dir="auto">var json_data=this.xmlToJson(body)</p>
<p dir="auto">then the json is accessed with the normal structure notation<br />
(using  the sample with the code in the last link)</p>
<p dir="auto">json_data.SD[0].SPEED.@attributes.TEXT will be ‘1421’</p>
<p dir="auto">SD is an array (multiple of same xml tags)</p>
<p dir="auto">a little ugly in the data layour, could get rid of the @attributes thing with a small code change</p>
]]></description><link>https://forum.magicmirror.builders/post/65964</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65964</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 17:57:15 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 17:43:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> , I’ve found them, but I don’t know how to use it in combination with the URL that creates the XML.</p>
<p dir="auto">Indeed the last one with no extra libs looks promising. I tried to simply add this in the node_helper.js  but getting stuck at how to use it.<br />
I’ve looked into all the MMM Modules but cannot seem to find an example.</p>
]]></description><link>https://forum.magicmirror.builders/post/65963</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65963</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 17:43:10 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 17:40:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/htilburgs" aria-label="Profile: htilburgs">@<bdi>htilburgs</bdi></a> there are a few xml to json modules</p>
<p dir="auto"><a href="https://www.npmjs.com/package/xml2js" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.npmjs.com/package/xml2js</a></p>
<p dir="auto">google search<br />
‘nodejs xmltojson’</p>
<p dir="auto">here is one with a just code, no extra libs</p>
<p dir="auto"><a href="https://davidwalsh.name/convert-xml-json" target="_blank" rel="noopener noreferrer nofollow ugc">https://davidwalsh.name/convert-xml-json</a></p>
]]></description><link>https://forum.magicmirror.builders/post/65962</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65962</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Fri, 13 Dec 2019 17:40:01 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Fri, 13 Dec 2019 17:30:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cowboysdude" aria-label="Profile: cowboysdude">@<bdi>cowboysdude</bdi></a>, I’m looking for the part where you “change” the XML data to JSON data. I’m trying to write a new MMM, but the data is presented in XML. I like the have it in JSON, so I can use it.</p>
<p dir="auto">Maybe I read over it, but I cannot figure out where you do this.</p>
]]></description><link>https://forum.magicmirror.builders/post/65961</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/65961</guid><dc:creator><![CDATA[htilburgs]]></dc:creator><pubDate>Fri, 13 Dec 2019 17:30:31 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Thu, 14 Nov 2019 21:29:48 GMT]]></title><description><![CDATA[<p dir="auto">Well, thanks to both of you! I can confirm it is finally working.</p>
<p dir="auto">Now to update github. Someday I should write some documentation too.</p>
]]></description><link>https://forum.magicmirror.builders/post/64449</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64449</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Thu, 14 Nov 2019 21:29:48 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Thu, 14 Nov 2019 03:06:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cowboysdude" aria-label="Profile: cowboysdude">@<bdi>cowboysdude</bdi></a> said in <a href="/post/64401">MMM-MealViewer</a>:</p>
<blockquote>
<p dir="auto">Sam is a REALLY smart guy so he gives you the smart guy answer</p>
</blockquote>
<p dir="auto">nah, Sam is the LAZY guy… change as LITTLE as possible. especially for folks just starting out</p>
]]></description><link>https://forum.magicmirror.builders/post/64406</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64406</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 14 Nov 2019 03:06:25 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Thu, 14 Nov 2019 02:43:26 GMT]]></title><description><![CDATA[<p dir="auto">Sam is a REALLY smart guy so he gives you the smart guy answer…<br />
I’m not as smart so I give you my dumb guy answer LOL</p>
<p dir="auto">It will work either way … so now you def have an answer that works :)</p>
]]></description><link>https://forum.magicmirror.builders/post/64401</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64401</guid><dc:creator><![CDATA[cowboysdude]]></dc:creator><pubDate>Thu, 14 Nov 2019 02:43:26 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Wed, 13 Nov 2019 19:41:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cowboysdude" aria-label="Profile: cowboysdude">@<bdi>cowboysdude</bdi></a> Thanks! I might switch to that. I’ve had to rework it a little because the URL wasn’t getting set except at the first call. I just moved setup for that into the getMenuData  and I think it’s all working now. I’ll give it a day to run and see what happens tomorrow before I try messing with it again and update the file on github.</p>
<p dir="auto">-updated to fix grammar</p>
]]></description><link>https://forum.magicmirror.builders/post/64374</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64374</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Wed, 13 Nov 2019 19:41:44 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Wed, 13 Nov 2019 02:34:16 GMT]]></title><description><![CDATA[<p dir="auto">Or you could do this:</p>
<pre><code>scheduleUpdate: function() {
       setInterval(() =&gt; {
           this.getMenuData();
       }, this.config.updateInterval); 
   },
    getMenuData: function() {
       this.sendSocketNotification('GET-MENU-DATA');
   }
</code></pre>
<p dir="auto">At the top of the main js you set the interval:</p>
<pre><code>updateInterval: 15 * 60 * 1000,
</code></pre>
<p dir="auto">Then in the start section you call it:</p>
<pre><code>// Define start sequence.
   start: function() {
       Log.info("Starting module: " + this.name); 
       this.scheduleUpdate();
   },
</code></pre>
<p dir="auto">Either the way Sam showed you or the above will work :)</p>
]]></description><link>https://forum.magicmirror.builders/post/64304</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64304</guid><dc:creator><![CDATA[cowboysdude]]></dc:creator><pubDate>Wed, 13 Nov 2019 02:34:16 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Wed, 13 Nov 2019 01:19:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a> Thanks! I’ll make the change and see what happens when it should update mid-day tomorrow.</p>
]]></description><link>https://forum.magicmirror.builders/post/64302</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64302</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Wed, 13 Nov 2019 01:19:40 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Wed, 13 Nov 2019 00:01:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gonzonia" aria-label="Profile: gonzonia">@<bdi>gonzonia</bdi></a> said in <a href="/post/64295">MMM-MealViewer</a>:</p>
<blockquote>
<p dir="auto">getMenuData: function(_this) {<br />
// Make the initial request to the helper then set up the timer to perform the updates<br />
_this.sendSocketNotification(‘GET-MENU-DATA’, _this.urls);<br />
setTimeout(_this.getMenuData(), _this.config.interval, _this);<br />
},</p>
</blockquote>
<p dir="auto">do this</p>
<pre><code> getMenuData: function(_this) {
    // Make the initial request to the helper then set up the timer to perform the updates
    _this.sendSocketNotification('GET-MENU-DATA', _this.urls);
    setTimeout(function() {_this.getMenuData(_this)}, _this.config.interval);
  },
</code></pre>
<p dir="auto">this creates a little inline function which CAN pass parms on to the next routine</p>
]]></description><link>https://forum.magicmirror.builders/post/64300</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64300</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Wed, 13 Nov 2019 00:01:39 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Tue, 12 Nov 2019 22:37:14 GMT]]></title><description><![CDATA[<p dir="auto">Okay. I’ve identified the problem. In the code below, everything gets setup in the “start” function. Then it calls getMenuData. That function ends by setting up a timer to call itself but isn’t supplying the object necessary. This means it won’t work. If I add the _this object to pass it causes all sorts of problems.<br />
I’m not a js expert. I’m sure a way to re-factor this will eventually occur to me, but right now I’m just not seeing it.</p>
<pre><code>start:  function() {
    Log.log('Starting module: ' + this.name);

    // Set up the local values
    var today = moment();
    this.loaded = false;
    this.urls = [];
    this.results = [];

    // Uses now are today if before noon and tomorrow as today if after noon
    if (today.hour() &gt;= 12) {
      var todayFormatted = today.add(1, 'day').format('MM-DD-YYYY');
    }
    else {
      var todayFormatted = today.format('MM-DD-YYYY');
    }

    // Currently set to only pull one day's data so endDayFormatted = todayFormatted
    //var endDay = today.add(config.showDays, 'days');
    //var endDayFormatted = endDay.format('MM-DD-YYYY');
    var endDayFormatted = todayFormatted;

    // Construct the url array for the schools
    for (var i in this.config.schools) {
			this.urls.push({school: this.config.schools[i], url: 'https://api.mealviewer.com/api/v4/school/' + this.config.schools[i] + '/' + todayFormatted + '/' + endDayFormatted + '/'});
    }

    // Trigger the first request
    this.getMenuData(this);
  },

  getMenuData: function(_this) {
    // Make the initial request to the helper then set up the timer to perform the updates
    _this.sendSocketNotification('GET-MENU-DATA', _this.urls);
    setTimeout(_this.getMenuData(), _this.config.interval, _this);
  },


</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/64295</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64295</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Tue, 12 Nov 2019 22:37:14 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Tue, 12 Nov 2019 12:16:55 GMT]]></title><description><![CDATA[<p dir="auto">The module works great on the initial load. The problem is that it doesn’t seem to be updating. After 12pm it’s supposed to start showing the next days meals but doesn’t. Even the next day it doesn’t update. I’ll try to dig into  the core aspects of developing a module and see if I can find out why, but if anyone with more experience has any ideas where I should start looking I’d appreciate it.</p>
]]></description><link>https://forum.magicmirror.builders/post/64248</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/64248</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Tue, 12 Nov 2019 12:16:55 GMT</pubDate></item><item><title><![CDATA[Reply to MMM-MealViewer on Mon, 14 Oct 2019 13:35:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sdetweil" aria-label="Profile: sdetweil">@<bdi>sdetweil</bdi></a><br />
Thanks. I actually went in to the code and tweaked it. It was pulling the data fine, I think the issue was that the original developer’s usage only had a single meal (Lunch) available at the school and so it worked as is. Our school has Breakfast and Lunch I added an additional iteration to show all the meals or just what was placed in the config. The header now also reflects that. I’m not sure what that was supposed to do before because I couldn’t figure out where it was expecting the data.header to come from since nothing was loaded.</p>
<p dir="auto">My changes can be found here.</p>
<p dir="auto"><a href="https://github.com/gonzonia/MMM-MealViewer/tree/patch-1" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/gonzonia/MMM-MealViewer/tree/patch-1</a><br />
added shortName to config to replace text based on config option instead of hardcoded<br />
changed className to menuWrapper to allow for style control without interfering with other modules<br />
added config option for showing single or multiple meals based on name, default is All</p>
<p dir="auto">Still need to add some documentation but it might be a couple of weeks.</p>
]]></description><link>https://forum.magicmirror.builders/post/62645</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/62645</guid><dc:creator><![CDATA[gonzonia]]></dc:creator><pubDate>Mon, 14 Oct 2019 13:35:44 GMT</pubDate></item></channel></rss>