• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

how to divide the payload of socketnotification

Scheduled Pinned Locked Moved Unsolved Troubleshooting
4 Posts 2 Posters 764 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    cycaaa
    last edited by May 6, 2019, 7:14 PM

    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?

    S 1 Reply Last reply May 6, 2019, 7:17 PM Reply Quote 0
    • S Away
      sdetweil @cycaaa
      last edited by May 6, 2019, 7:17 PM

      @cycaaa can u show the payload?

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      C 1 Reply Last reply May 6, 2019, 10:50 PM Reply Quote 0
      • C Offline
        cycaaa @sdetweil
        last edited by May 6, 2019, 10:50 PM

        @sdetweil
        is my payload.
        0_1557182965874_캡처.PNG image url)

        S 1 Reply Last reply May 6, 2019, 11:22 PM Reply Quote 0
        • S Away
          sdetweil @cycaaa
          last edited by sdetweil May 7, 2019, 1:57 AM May 6, 2019, 11:22 PM

          @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(’ '))

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          1 / 1
          • First post
            1/4
            Last post
          Enjoying MagicMirror? Please consider a donation!
          MagicMirror created by Michael Teeuw.
          Forum managed by Sam, technical setup by Karsten.
          This forum is using NodeBB as its core | Contributors
          Contact | Privacy Policy