-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_helper.js
37 lines (30 loc) · 1.1 KB
/
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
const exec = require('child_process').exec;
var NodeHelper = require('node_helper')
module.exports = NodeHelper.create({
start: function() {
this.config = {}
},
stop: function() {
},
socketNotificationReceived: function (notification, payload) {
const self = this;
switch (notification) {
case 'dependencyCheck':
exec('python3 ./modules/MMM-Plantower/dependencyCheck.py', (error, stdout) => {
if (error) {
throw "Please install plantower with pip";
}
});
break;
case 'retrieveData':
exec('python3 ./modules/MMM-Plantower/pollData.py ' + payload, (error, stdout) => {
if (error) {
throw error + "Something went wrong while reading data.";
}
let recievedData = JSON.parse(stdout);
self.sendSocketNotification('retrieveDataReturn', recievedData);
});
break;
}
}
})