<?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[Connecting Modules to Each Other]]></title><description><![CDATA[<p dir="auto">Hello!</p>
<p dir="auto">I am wanting to take the variables from a weather module and use that to decide a background. Do I need to rebuild current weather in my module, or can i import it essentially in order to use the variables / gather temps?</p>
<p dir="auto">Thank you for your time!</p>
]]></description><link>https://forum.magicmirror.builders/topic/15703/connecting-modules-to-each-other</link><generator>RSS for Node</generator><lastBuildDate>Sun, 09 Aug 2026 10:44:51 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/15703.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 06 Oct 2021 15:14:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 23:04:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> glad you are making progress.</p>
<p dir="auto">not a JS problem. any language would have the same problem…</p>
]]></description><link>https://forum.magicmirror.builders/post/95369</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95369</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 23:04:04 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 22:55:43 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> Great advice.</p>
<p dir="auto">I stepped through and you were right on two things. When it starts, it defaults with the else case, because it hasn’t fetched the type yet. Once it does fetch the type I was resetting it in the myJob() function causing it to be undefined again.</p>
<p dir="auto">I appreciate the break down on this. JS is definitely giving me a run for my money on learning it.</p>
]]></description><link>https://forum.magicmirror.builders/post/95368</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95368</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 22:55:43 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 22:20:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> correct</p>
]]></description><link>https://forum.magicmirror.builders/post/95366</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95366</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 22:20:26 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 21:53: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> when you say stop you mean in my debug to see where im losing the value?</p>
]]></description><link>https://forum.magicmirror.builders/post/95365</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95365</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 21:53:57 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 21:50:12 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> I would put a stop everywhere u set it.</p>
<p dir="auto">make sure the this. pointer is pointing to the same place set vs use</p>
]]></description><link>https://forum.magicmirror.builders/post/95364</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95364</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 21:50:12 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 21:39:55 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> funny you say that. Ive been reading and you offered the solution on someone using compliments + weather. My issue is when i step through to set image, the type is back to undefined and not carried from the notification. Im wondering if its in my order as to why its going back to undefined</p>
]]></description><link>https://forum.magicmirror.builders/post/95362</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95362</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 21:39:55 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 21:40:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> should be able to save the payload pointer and then use that day later. I do it all the time</p>
<p dir="auto">this.weatherInfo = payload</p>
<p dir="auto">for example</p>
<p dir="auto">remember your module could get called at getDom() long before the other module sends the notification, so u need to check if it has arrived yet.</p>
]]></description><link>https://forum.magicmirror.builders/post/95361</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95361</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 21:40:21 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 21:32:46 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> that definitely was part of it.</p>
<p dir="auto">I am able to successfully see the payload in notifications. Just working a way to retain it and be able to use in setImage. Thank you!</p>
]]></description><link>https://forum.magicmirror.builders/post/95360</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95360</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 21:32:46 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 20:04:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> well</p>
<pre><code>setImage: function () {
  let rand = Math.floor(Math.random() * 4)+1; //randomn number to pick gif
	var day = new Date();
	var hour = day.getHours();
	var type = this.currentWeatherTemperature;   // &lt; ----
</code></pre>
<p dir="auto">notification</p>
<pre><code>//From data currentweather set weather type
	setCurrentWeatherType: function(type){
	this.currentWeatherType = type;    // &lt; ----
},

notificationReceived: function (notification, payload, sender) {
	  if (notification === 'DOM_OBJECTS_CREATED') {
	    this.job()
	  }
//weather dom
	if(notification === "CURRENTWEATHER_TYPE"){
		this.setCurrentWeatherType(payload.type);
	}
},
</code></pre>
<p dir="auto">this.currentWeatherTemperature is NOT this.currentWeatherType</p>
]]></description><link>https://forum.magicmirror.builders/post/95356</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95356</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 20:04:29 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 19:29: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> great callout! I did not know I could debug. I do get a type back. I did the break trick on where its in an if statement and the type is still undefined in setImage</p>
]]></description><link>https://forum.magicmirror.builders/post/95355</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95355</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 19:29:40 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 19:28:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a><br />
Hmmmm…  I cannot understand the <code>setCurrentWeatherType</code>.</p>
<p dir="auto">Anyway, I recommend you this module; <a href="https://github.com/BrianHepler/MMM-WeatherBackground" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/BrianHepler/MMM-WeatherBackground</a><br />
You need to study how MM module works, at least to train how to use.</p>
<p dir="auto">You don’t need to pull weather info from an external weather API like Darksky. Already there are many modules showing weather info on MM screen and spitting that info out through <code>notification</code>.</p>
<p dir="auto">For example, default <code>weather</code> module also emit notifications of weather info periodically. All you need to do is catching that notification and consume them in your module.</p>
<p dir="auto">default <code>weather</code> module would emit <code>CURRENTWEATHER_TYPE</code> notification.<br />
You can catch that notification like this.</p>
<pre><code class="language-js">
notificationReceived: function (notification, payload, sender) {
  if (notification === 'CURRENTWEATHER_TYPE') {
     console.log(payload) // manipulate payload then extract data what you need.
     // do your job
  }
}
</code></pre>
<p dir="auto">Anyway, Study the above module. That has almost all features you are trying. (except the image source)</p>
]]></description><link>https://forum.magicmirror.builders/post/95354</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95354</guid><dc:creator><![CDATA[MMRIZE]]></dc:creator><pubDate>Thu, 07 Oct 2021 19:28:15 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 19:18:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a> maybe the payload in the notification doesn’t have ‘type’</p>
<p dir="auto">u can debug the code in the developers window, ctrl-shift-i, select the source tab,<br />
and navigate to your module and select the js file</p>
<p dir="auto">then the source will appear on the right…</p>
<p dir="auto">to stop at an instruction</p>
<p dir="auto">click the line number  in the left edge of the source display, it should turn blue</p>
<p dir="auto">then fresh the page (f5)</p>
<p dir="auto">and code will stop there, you can examine and change the variables/data and step thru the code (the   dot with the curved arrow over it, is step one instruction at a time. )</p>
<p dir="auto">to resume, hit run (blue arrow) and if the debugger is still up, it will stop there again at the next time<br />
(if u stopped on a weather notification for example)</p>
]]></description><link>https://forum.magicmirror.builders/post/95353</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95353</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Thu, 07 Oct 2021 19:18:58 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Thu, 07 Oct 2021 19:14:54 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mmrize" aria-label="Profile: mmrize">@<bdi>mmrize</bdi></a> I took some time to try and figure this one out… sadly a lot of weather API’s are falling out, so some references use darkskies and that is out. I did write this up and so far the only issue I am having is at setImage the type variable is not being filled with a value.</p>
<p dir="auto">When i run npm start dev and I have the log return the value of type it does say info undefined… so it seems im not pulling off currentweather correctly with openweather as my api</p>
<pre><code>defaults: {
        height: "600px",   // your display's resolution in pixels. Enter in config.js
        width: "1024px",    // your display's resolution in pixels. Enter in config.js
        updateInterval: 60 * 60 * 100,
    },
//set current weather from moduel
currentWeatherType: "weather, currentweather",
//scripts
getScripts: function(){
	return ["moment.js" , "moment-timezone.js"];
},
   
	
start: function () {
	  this.timer = null
	  this.url = null
	  this.setImage()
},

getDom: function () {
	  console.log("&gt;", this.url)
	  var dom = document.createElement('div')
	  dom.style.backgroundImage = `url(${this.url})`
	  dom.style.height = '100vh' // do in css
	  dom.style.width = '100vw'
	  dom.style.backgroundSize = 'cover'
	  return dom
},
//From data currentweather set weather type
	setCurrentWeatherType: function(type){
	this.currentWeatherType = type;
},

notificationReceived: function (notification, payload, sender) {
	  if (notification === 'DOM_OBJECTS_CREATED') {
	    this.job()
	  }
//weather dom
	if(notification === "CURRENTWEATHER_TYPE"){
		this.setCurrentWeatherType(payload.type);
	}
},


job: function () {
	  clearTimeout(this.timer)
      	  this.updateDom()
     	  this.setImage()
  	  this.timer = setTimeout(() =&gt; {
    	  this.job()
  	}, this.config.updateInterval)
},


setImage: function () {
  let rand = Math.floor(Math.random() * 4)+1; //randomn number to pick gif
	var day = new Date();
	var hour = day.getHours();
	var type = this.currentWeatherTemperature;
//if criteria for folders
//	if(hour &gt;= 22 || hour &lt;= 4){
//	folder = "Night";
//	}else
//	if(hour &lt;= 10){
//	folder = "Morning";
//	}else
//	if(hour &lt;= 17){
//	folder = "Afternoon";

	if(type = "rain"){ //testing weather to see if it passes if condition
		folder = "Afternoon";
	}else folder = "Morning";

	this.url = "modules/MMM-MainScreen/images/" + folder +"/" + rand +".gif";
	}

});
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/95351</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95351</guid><dc:creator><![CDATA[tonkxy]]></dc:creator><pubDate>Thu, 07 Oct 2021 19:14:54 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Wed, 06 Oct 2021 16:08:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a><br />
And there be already similar modules. Look inside and study how they did.</p>
]]></description><link>https://forum.magicmirror.builders/post/95324</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95324</guid><dc:creator><![CDATA[MMRIZE]]></dc:creator><pubDate>Wed, 06 Oct 2021 16:08:06 GMT</pubDate></item><item><title><![CDATA[Reply to Connecting Modules to Each Other on Wed, 06 Oct 2021 16:05:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tonkxy" aria-label="Profile: tonkxy">@<bdi>tonkxy</bdi></a><br />
Usually some module might spit out some notifications with various data those want to be consumed.<br />
With luck you can gather all data you need from the notifications.</p>
<p dir="auto">Some modules might provide public method functions to interact with other modules.</p>
<p dir="auto">Some modules might provide WebAPI url endpoints to communicate with world.</p>
<p dir="auto">Well, even if there exists nothing to use, you can inject or reassign(overwrite) MM module methods for your needs, because MM module is not encapsulated by default.</p>
]]></description><link>https://forum.magicmirror.builders/post/95323</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/95323</guid><dc:creator><![CDATA[MMRIZE]]></dc:creator><pubDate>Wed, 06 Oct 2021 16:05:59 GMT</pubDate></item></channel></rss>