-
Notifications
You must be signed in to change notification settings - Fork 28
/
node_helper.js
36 lines (32 loc) · 919 Bytes
/
node_helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* Magic Mirror
* Node Helper: MMM-SmartTouch
*
* By SmartBuilds.io - Pratik and Eben
* https://smartbuilds.io
* MIT Licensed.
*/
const NodeHelper = require("node_helper")
module.exports = NodeHelper.create({
start: function () {
this.started = false;
this.config = {};
},
socketNotificationReceived: function (notification, payload) {
if (notification === 'CONFIG') {
if (!this.started) {
this.config = payload;
this.started = true;
console.log("Smart Touch module has started")
this.sendSocketNotification("SHUTIT", payload);
}
}
if (notification === "SHUTDOWN") {
console.log("Shutting down Rpi...")
require('child_process').exec('shutdown -h now', console.log)
}
if (notification === "RESTART") {
console.log("Restarting Rpi...")
require('child_process').exec('sudo reboot', console.log)
}
},
});