<?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[help converting code for module...]]></title><description><![CDATA[<p dir="auto">Anybody know how I can turn the following :</p>
<pre><code>function Get-Temperature {
$t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi" | where -Property instancename -EQ "ACPI\ThermalZone\TZ01_0"

$currentTempKelvin = $t.CurrentTemperature / 10
$currentTempCelsius = $currentTempKelvin - 273.15

$currentTempFahrenheit = (9/5) * $currentTempCelsius + 32

return $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K"  
}
</code></pre>
<p dir="auto">into MM module fomat?</p>
<p dir="auto">I tried this:</p>
<pre><code>getTemperature: function() {
		t = getWmiObject = MSAcpi_ThermalZoneTemperature (Namespace = "root/wmi" | where (Property = instancename) (EQ = "ACPI\ThermalZone\TZ01_0"));
		
	    currentTempKelvin = $t.CurrentTemperature / 10;
		currentTempCelsius = $currentTempKelvin - 273.15;
		
		currentTempFahrenheit = (9/5) * $currentTempCelsius + 32;
		
		return currentTempCelsius.ToString() + " C : " + currentTempFahrenheit.ToString() + " F : " + currentTempKelvin + "K";
	},
</code></pre>
<p dir="auto">didn’t get any errors, but didn’t get any resulting expected outcome either…</p>
<p dir="auto">Any hints would be greatly appreciated!!!<br />
Thanks in advance! :upside-down_face:</p>
]]></description><link>https://forum.magicmirror.builders/topic/8976/help-converting-code-for-module</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Jul 2026 04:07:29 GMT</lastBuildDate><atom:link href="https://forum.magicmirror.builders/topic/8976.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 26 Oct 2018 00:56:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to help converting code for module... on Tue, 30 Oct 2018 08:24:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a></p>
<pre><code>
const exec = require('child_process').exec
var NodeHelper = require("node_helper")

module.exports = NodeHelper.create({
  socketNotificationReceived: function(noti, payload) {
    if (noti == "GIVE_ME_RESULT") {
      setTimeout(()=&gt;{
        exec("C:\WINDOWS\system32\get-temperature", //I don't know WINDOWS system at all. Is it right?
          (err, sto, ste) =&gt; {
            if (!err) {
              this.sendSocketNotification("HERE_IS_RESULT", sto)
            } else {
              console.log("Error", err)
            }
          }
        )
      }, 1000)
    }
  }
})
</code></pre>
<p dir="auto">It isn’t tested. But you can catch the idea.</p>
]]></description><link>https://forum.magicmirror.builders/post/46108</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46108</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 30 Oct 2018 08:24:17 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Tue, 30 Oct 2018 01:34:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> let’s look at the design of your module.</p>
<p dir="auto">How often do u need to get the temps?<br />
Is it on a timer, or some other mechanism?</p>
<p dir="auto">Anyhow, on that cycle, you would issue the ‘run’ of the powershell app in the node_helper.js, and capture it’s output.</p>
<p dir="auto">Then process the output, remove all the useless data.  Then send the raw data to the module.js, who will then format the HTML in the get_dom() function for display</p>
]]></description><link>https://forum.magicmirror.builders/post/46103</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46103</guid><dc:creator><![CDATA[sdetweil]]></dc:creator><pubDate>Tue, 30 Oct 2018 01:34:05 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Tue, 30 Oct 2018 00:45:47 GMT]]></title><description><![CDATA[<p dir="auto">@sean</p>
<p dir="auto">Yes, that is the command to get the temps from the PC using powershell or command prompt…</p>
<p dir="auto">BUT, where to use the command in node_helper.js?</p>
<p dir="auto">OR, where to use the command in the module.js file?</p>
]]></description><link>https://forum.magicmirror.builders/post/46100</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46100</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Tue, 30 Oct 2018 00:45:47 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Tue, 30 Oct 2018 00:30:58 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a><br />
**<br />
PS C:\WINDOWS\system32&gt; get-temperature<br />
**<br />
I don’t know anything about your intention, but ‘get-temperature’ could be executable in your shell or terminal, it could be the one.</p>
]]></description><link>https://forum.magicmirror.builders/post/46098</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46098</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Tue, 30 Oct 2018 00:30:58 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Tue, 30 Oct 2018 00:07:17 GMT]]></title><description><![CDATA[<p dir="auto">@sean</p>
<p dir="auto">Not sure I follow …</p>
<p dir="auto">what would be my ‘shell command’?</p>
]]></description><link>https://forum.magicmirror.builders/post/46097</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46097</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Tue, 30 Oct 2018 00:07:17 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Mon, 29 Oct 2018 07:56:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a></p>
<pre><code>exec(“YOUR-SHELL-COMMAND”, (error, stdout, stderr)=&gt;{
  console.log(stdout)
  // do your job with `stdout`
})
</code></pre>
<p dir="auto">I think you can get the result of any execution of shell script.</p>
]]></description><link>https://forum.magicmirror.builders/post/46056</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46056</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Mon, 29 Oct 2018 07:56:53 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Mon, 29 Oct 2018 01:33:29 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">What are the chances of being able to do what I had been attempting with this?<br />
<a href="https://github.com/moxystudio/node-cross-spawn" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/moxystudio/node-cross-spawn</a></p>
<p dir="auto">And would it be possible to add to a current node_helper being used for linux, or would a separate node_helper or script need made?</p>
]]></description><link>https://forum.magicmirror.builders/post/46052</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/46052</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Mon, 29 Oct 2018 01:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 06:39:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> if you don’t even have the data in js, you can also execute it in the node helper and parse the response <a href="https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback" target="_blank" rel="noopener noreferrer nofollow ugc">https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback</a></p>
]]></description><link>https://forum.magicmirror.builders/post/45991</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45991</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sat, 27 Oct 2018 06:39:39 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 01:12:53 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">I had a syntax error in the declaration of Temps.</p>
<p dir="auto">I’m totally thinking this isn’t going to work.</p>
<p dir="auto">I will probably need to find a different way,<br />
figured if I could pull it from the SIMBIOS using a simple script, that maybe it could be pulled using a module for MM.</p>
<p dir="auto">there are some open source apps for Windows that work to get the data, I will just have to study them and see what I can come up with.</p>
<p dir="auto">Thanks for trying to help.</p>
]]></description><link>https://forum.magicmirror.builders/post/45988</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45988</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 01:12:53 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 01:08:41 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">I defined Temps. then got this in console…</p>
<pre><code>MMM-PC-Stats.js:104 Uncaught (in promise) TypeError: Cannot read property '
ootwmi:MSAcpi_ThermalZoneTemperature' of undefined
    at Class.getDom (MMM-PC-Stats.js:104)
    at main.js:110
    at new Promise (&lt;anonymous&gt;)
    at updateDom (main.js:109)
    at Object.updateDom (main.js:514)
    at Class.updateDom (module.js:358)
    at Class.socketNotificationReceived (MMM-PC-Stats.js:213)
    at module.js:246
    at r.&lt;anonymous&gt; (socketclient.js:25)
    at r.emit (index.js:133)
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/45987</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45987</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 01:08:41 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 01:06:19 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> if the variable doesn’t even exist, the rest of the code cannot work at all. first you should make sure that you have your data in the variable and then the second step is displaying it.</p>
<p dir="auto">It seems like you’re trying to do the ui before you have the data.</p>
]]></description><link>https://forum.magicmirror.builders/post/45986</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45986</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sat, 27 Oct 2018 01:06:19 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 01:02:23 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">it throws this error…</p>
<pre><code>Uncaught (in promise) ReferenceError: Temps is not defined
    at Class.getDom (MMM-PC-Stats.js:103)
    at main.js:110
    at new Promise (&lt;anonymous&gt;)
    at updateDom (main.js:109)
    at Object.updateDom (main.js:514)
    at Class.updateDom (module.js:358)
    at Class.socketNotificationReceived (MMM-PC-Stats.js:218)
    at module.js:246
    at r.&lt;anonymous&gt; (socketclient.js:25)
    at r.emit (index.js:133)
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/45985</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45985</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 01:02:23 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 00:27:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> I can’t work with your powershell logs. You’re trying to access the variable Temps in js like your first line. <code>var checkSensorTemps = Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"];</code><br />
can you do console.log(Temps) so I can see the structure?</p>
]]></description><link>https://forum.magicmirror.builders/post/45984</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45984</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sat, 27 Oct 2018 00:27:37 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 00:22:10 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">this script ran in powershell …</p>
<pre><code>function Get-Temperature {
    $t = Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"
    $returntemp = @()

    foreach ($temp in $t.CurrentTemperature)
    {
        $currentTempKelvin = $temp / 10
        $currentTempCelsius = $currentTempKelvin - 273.15
        $currentTempFahrenheit = (9/5) * $currentTempCelsius + 32
        $returntemp += $currentTempCelsius.ToString() + " C : " + $currentTempFahrenheit.ToString() + " F : " + $currentTempKelvin + "K"  
    }
    return $returntemp
}
</code></pre>
<p dir="auto">gives the following output for a single core …</p>
<pre><code>PS C:\WINDOWS\system32&gt; get-temperature
44.05 C : 111.29 F : 317.2K
</code></pre>
<p dir="auto">I’m really only interested in a C and F result, no need for K that I can think of.</p>
]]></description><link>https://forum.magicmirror.builders/post/45983</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45983</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 00:22:10 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 00:19:07 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<pre><code>PS C:\WINDOWS\system32&gt; powershell.exe Get-WmiObject MSAcpi_ThermalZoneTemperature -Namespace "root/wmi"


__GENUS              : 2
__CLASS              : MSAcpi_ThermalZoneTemperature
__SUPERCLASS         : MSAcpi
__DYNASTY            : MSAcpi
__RELPATH            : MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\THRM_0"
__PROPERTY_COUNT     : 12
__DERIVATION         : {MSAcpi}
__SERVER             : DESKTOP-BEUARKC
__NAMESPACE          : root\wmi
__PATH               : \\DESKTOP-BEUARKC\root\wmi:MSAcpi_ThermalZoneTemperature.InstanceName="ACPI\\ThermalZone\\THRM_0
                       "
Active               : True
ActiveTripPoint      : {0, 0, 0, 0...}
ActiveTripPointCount : 0
CriticalTripPoint    : 3762
CurrentTemperature   : 3172
InstanceName         : ACPI\ThermalZone\THRM_0
PassiveTripPoint     : 3882
Reserved             : 0
SamplingPeriod       : 100
ThermalConstant1     : 2
ThermalConstant2     : 10
ThermalStamp         : 25
PSComputerName       : DESKTOP-BEUARKC
</code></pre>
]]></description><link>https://forum.magicmirror.builders/post/45982</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45982</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 00:19:07 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 00:08:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> do you have a log of the structure of Temps</p>
]]></description><link>https://forum.magicmirror.builders/post/45981</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45981</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Sat, 27 Oct 2018 00:08:44 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Sat, 27 Oct 2018 00:00:07 GMT]]></title><description><![CDATA[<p dir="auto">latest attempt with this code…</p>
<pre><code>var checkSensorTemps = Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"];
if (typeof checkSensorTemps !== "undefined") {

	// Core Temps
	var core0Temp = document.createElement("div");
	core0Temp.classList.add("large", "bright", "core0Temp");
	core0Temp.innerHTML = Stats.cpu.threads[i].name + " &amp;nbsp  @  &amp;nbsp " 
		+ ((Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"].value / 10) -273.15) + " &amp;deg;C "
		+ ((((Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"].value / 10) -273.15) * 9/5) + 32) + " &amp;deg;F "
		+ (Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"].value  / 10) + "&amp;deg;K";
	wrapper.appendChild(core0Temp);
}
</code></pre>
<p dir="auto">HELP! LMAO! :face_with_stuck-out_tongue_winking_eye:</p>
]]></description><link>https://forum.magicmirror.builders/post/45978</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45978</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Sat, 27 Oct 2018 00:00:07 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Fri, 26 Oct 2018 06:02:47 GMT]]></title><description><![CDATA[<p dir="auto">I need to know how to reconfigure the second line for this work in an MM module…</p>
<pre><code>getTemperature: function() {
	var t = getWmiObject = MSAcpi_ThermalZoneTemperature(Namespace = "root/wmi" | where (Property = instancename) &amp;&amp; (EQ = "ACPI\ThermalZone\TZ01_0"));
	currentTempKelvin = t.CurrentTemperature / 10;
	currentTempCelsius = currentTempKelvin - 273.15;
	currentTempFahrenheit = (9/5) * currentTempCelsius + 32;		
	return currentTempCelsius + " C " + currentTempFahrenheit + " F : " + currentTempKelvin + "K";
},
</code></pre>
<p dir="auto">I’m pretty sure rest of the function is ok. But, I could be wrong! :disappointed_face:</p>
]]></description><link>https://forum.magicmirror.builders/post/45937</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45937</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Fri, 26 Oct 2018 06:02:47 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Fri, 26 Oct 2018 05:46:16 GMT]]></title><description><![CDATA[<p dir="auto">@strawberry-3-141</p>
<p dir="auto">yeah, sorry, I see some of the errors, but not all of them.</p>
<p dir="auto">Want to hint me a little?</p>
]]></description><link>https://forum.magicmirror.builders/post/45936</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45936</guid><dc:creator><![CDATA[justjim1220]]></dc:creator><pubDate>Fri, 26 Oct 2018 05:46:16 GMT</pubDate></item><item><title><![CDATA[Reply to help converting code for module... on Fri, 26 Oct 2018 05:29:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/justjim1220" aria-label="Profile: justjim1220">@<bdi>justjim1220</bdi></a> this is not JavaScript, there are errors on all lines. Not sure why you didn’t see errors, are you sure you called that function?</p>
]]></description><link>https://forum.magicmirror.builders/post/45934</link><guid isPermaLink="true">https://forum.magicmirror.builders/post/45934</guid><dc:creator><![CDATA[strawberry 3.141]]></dc:creator><pubDate>Fri, 26 Oct 2018 05:29:47 GMT</pubDate></item></channel></rss>