Read the statement by Michael Teeuw here.
SleepWake twisted....need help
-
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 } -
@justonemore node_helper cannot communicate with any module except its own
via sendSocketNotification()
the MODULEname.js can then talk to other modules
via sendNotification()
here is a diagram of the design

SO, the helper sends the notification up to its module which then forwards it on
this.sendSocketNotification('send this to others', {notification:ID_of_message_to_other_modules, content: actual_message_content})MODULEname.js does
socketNotificationReceived(notice, payload){ if(notice === 'send this to others') this.sendNotification(payload.notification, payload.content) } -
@sdetweil Thank you…
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login