I am trying to use MMM-SleepWake module from sdetweil (real good by the way) to communicate with my own module but can’t figure out what is wrong…everytime MMM-SleepWake wakes, it runs a python program through a function I created in the MMM-SleepWake node_helper file…It runs fine when I uncomment the console.log and comment the sendNotification lines so I know it is working. What I don’t get is how to send the data to my own module…I tried self.sendNotification, this.sendNotification and sendNotification but all of them return an error the function is not defined…how to I send “data” to my MMM-Facez module ?
Python function included in node_helper from MMM-SleepWake.
start_python: function() {
let self = this;
var py_recog = spawn('python3', ['-u', '/home/pi/MagicMirror/modules/MMM-Facez/recognize.py']);
py_recog.stdout.on('data', function (data) {
// console.log(data.toString());
sendNotification("ATUALIZA_FACEZ", data);
});
py_recog.stderr.on('data', function(data) {
console.log('Python returned Error: ', data.toString()); });
py_recog.on('exit', function (code, signal) {
console.log('Python exited with ' +
`code ${code} and signal ${signal}`); });
},
Error I get :
[20.05.2021 18:33.47.306] [ERROR] ReferenceError: sendNotification is not defined
at Socket.<anonymous> (/home/pi/MagicMirror/modules/MMM-SleepWake/node_helper.js:23:7)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
my MMM-Facez.js module
notificationReceived: function(notification, payload, sender) {
switch(notification) {
case "ATUALIZA_FACEZ":
var elem = document.getElementById("TITULO")
this.nomepessoa = payload
elem.innerHTML = this.nomepessoa
break
}
},
socketNotificationReceived: function(notification, payload) {
switch(notification) {
case "ATUALIZA_FACEZ":
var elem = document.getElementById("TITULO")
this.nomepessoa = payload
elem.innerHTML = this.nomepessoa
break
}