File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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.
33It 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
Original file line number Diff line number Diff line change 11var NodeHelper = require ( "node_helper" ) ;
22var exec = require ( 'child_process' ) . exec ;
3- var fs = require ( 'fs' ) ;
43
54module . 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} ) ;
You can’t perform that action at this time.
0 commit comments