Read the statement by Michael Teeuw here.
how to divide the payload of socketnotification
-
I have this problem. The code below sends an alert to Socket Notify and other modules handle the notification.
sendNotification ‘result’
socketNotificationReceived: function(notification, payload) { switch(notification) { case "TEST": console.log("notification : " + notification) PythonShell.run('c://Users/user/Desktop/MagicMirror-master/modules/MMM-Testpython/FCF.py', null, function (err, result) { if (err) throw err; console.log("sex" + result); socketTestpython.sendSocketNotification("I_DID",result); }); break } }recived notification but the ‘split’ doesn’t work.
The log with the payload as a factor is well show. but Payload 3 is not show.}, socketNotificationReceived: function(notification, payload) { switch(notification) { case "I_DID": console.log("Socket recevied 1: " + payload); var payload3; payload3=payload.split("_"); console.log("Socket recevied 1: " + payload3); var elemk = document.getElementById("showage"); var sex = payload3[0]; console.log("Socket recevied 1: " + sex); var age = payload3[1]; console.log("Socket recevied 1: " + age); var change; if (sex == "Male"){Why doesn’t the split work?
-
@cycaaa can u show the payload?
-
@sdetweil
is my payload.
image url) -
@cycaaa looks like result in node_helper is not a string object
according to the doc, results is an array
PythonShell.run('my_script.py', options, function (err, results) { if (err) throw err; // results is an array consisting of messages collected during execution console.log('results: %j', results); });SO, you need to get them all, so, sendSocketNotification(“string”,results.join(’ '))
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