Skip to content

Commit e3a5c8b

Browse files
authored
Enable functionality on all Linux-based systems
1 parent 3bd2b6d commit e3a5c8b

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Module: MMM-SystemTemperature
2-
This MagicMirror modules allows you to show your processor temperature on you mirror. Currently it only works with a Raspberry Pi.
2+
This MagicMirror modules allows you to show your processor temperature on you mirror.
33
It also allows to safely shutdown the Raspberry Pi using [MMM-Remote-Control](https://github.com/Jopyth/MMM-Remote-Control) if you configure it.
44

55
## Installation

node_helper.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var NodeHelper = require("node_helper");
22
var exec = require('child_process').exec;
3-
var fs = require('fs');
43

54
module.exports = NodeHelper.create({
65
start: function() {
@@ -18,20 +17,16 @@ module.exports = NodeHelper.create({
1817
},
1918

2019
sendTemperature: function() {
21-
var command = "/opt/vc/bin/vcgencmd measure_temp"
22-
23-
// Since on 64 bit OS's like Raspbian, path to vcgencmd is different
24-
// we need to adjust it accordingly
25-
if (fs.existsSync(command) === false) {
26-
command = "/usr/bin/vcgencmd measure_temp"
27-
}
28-
20+
var command = "cat /sys/class/thermal/thermal_zone*/temp"
21+
2922
exec(command, (error, stdout, stderr) => {
3023
if (error) {
3124
console.log(error);
3225
return;
3326
}
34-
this.sendSocketNotification('TEMPERATURE', parseFloat(stdout.replace('temp=','')));
27+
var temperatures = stdout.trim().split('\n').map((t) => parseInt(t));
28+
var average = temperatures.reduce((a, b) => a + b, 0) / temperatures.length || 0;
29+
this.sendSocketNotification('TEMPERATURE', (average / 1000).toFixed(2));
3530
});
3631
}
3732
});

0 commit comments

Comments
 (0)