Read the statement by Michael Teeuw here.
help converting code for module...
-
this script ran in powershell …
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 }
gives the following output for a single core …
PS C:\WINDOWS\system32> get-temperature 44.05 C : 111.29 F : 317.2K
I’m really only interested in a C and F result, no need for K that I can think of.
-
@justjim1220 I can’t work with your powershell logs. You’re trying to access the variable Temps in js like your first line.
var checkSensorTemps = Temps["\root\wmi:MSAcpi_ThermalZoneTemperature"]["ACPI\ThermalZone"]["THRM_0"];
can you do console.log(Temps) so I can see the structure? -
it throws this error…
Uncaught (in promise) ReferenceError: Temps is not defined at Class.getDom (MMM-PC-Stats.js:103) at main.js:110 at new Promise (<anonymous>) 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.<anonymous> (socketclient.js:25) at r.emit (index.js:133)
-
@justjim1220 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.
It seems like you’re trying to do the ui before you have the data.
-
I defined Temps. then got this in console…
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 (<anonymous>) 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.<anonymous> (socketclient.js:25) at r.emit (index.js:133)
-
I had a syntax error in the declaration of Temps.
I’m totally thinking this isn’t going to work.
I will probably need to find a different way,
figured if I could pull it from the SIMBIOS using a simple script, that maybe it could be pulled using a module for MM.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.
Thanks for trying to help.
-
@justjim1220 if you don’t even have the data in js, you can also execute it in the node helper and parse the response https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
-
What are the chances of being able to do what I had been attempting with this?
https://github.com/moxystudio/node-cross-spawnAnd 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?
-
exec(“YOUR-SHELL-COMMAND”, (error, stdout, stderr)=>{ console.log(stdout) // do your job with `stdout` })
I think you can get the result of any execution of shell script.
-
@sean
Not sure I follow …
what would be my ‘shell command’?