• 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.

Problem with sending socket notification to module

Scheduled Pinned Locked Moved Unsolved Troubleshooting
8 Posts 3 Posters 1.9k Views 3 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.
  • P Offline
    PerBa
    last edited by Jul 13, 2019, 3:46 PM

    Re: Problem with sending socket notification to module

    The line of code that sends the notification is:

    getDepartures: function () {
    var self = this;
    ...
    self.sendSocketNotification('DEPARTURES', CurrentDeparturesArray); 
    

    the corresponding code in the module is:

    socketNotificationReceived: function (notification, payload) {
    	Log.info('MODULE:: received notification');
    	Log.info("Received Notification" + notification);
            if (notification === 'DEPARTURES') {
    

    Thanks!

    S 1 Reply Last reply Jul 13, 2019, 3:50 PM Reply Quote 0
    • S Offline
      sdetweil @PerBa
      last edited by sdetweil Jul 13, 2019, 3:51 PM Jul 13, 2019, 3:50 PM

      @PerBa

      getDepartures: function () {
      var self = this;
      

      Careful. getDepartures is not called by mm, so it’s very likely that ‘this’ is NOT pointing to the node_module instance.

      Save ‘this’ when u get the 1st socketnotification only. Just once.

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      1 Reply Last reply Reply Quote 0
      • P Offline
        PerBa
        last edited by Jul 14, 2019, 6:50 AM

        Thanks for the help!
        I don’t know what happend, but I forgot to turn off the Pi during the night. This morning the Pi had crashed. I did a power-toggle and now one of the modules (the one I cleaned up regarding the “this-self”) is working.

        I must look more into this.

        Update: I now know what is behind the problem!!!
        After a power toggle everything works OK. But when I stop and restart the MagicMirror using

        pm2 stop mm
        

        and

        pm2 start mm
        

        The modules stop working.

        Does anybody know a better way of restarting the Magic Mirror?
        I must be able to do that in order to test the changes I do to the configuration…

        S D 3 Replies Last reply Jul 14, 2019, 2:14 PM Reply Quote 0
        • S Offline
          sdetweil @PerBa
          last edited by sdetweil Jul 15, 2019, 3:21 PM Jul 14, 2019, 2:14 PM

          @PerBa I do this start/stop a hundred times a day without problem.

          I kill all the node processes
          I don’t use pm2

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • D Offline
            dazza120 @PerBa
            last edited by Jul 14, 2019, 8:10 PM

            @PerBa is this a Pi4 or Buster? Seems to be loads of issues with one of these. @sdetweil is the man to help though

            1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @PerBa
              last edited by Jul 15, 2019, 3:26 PM

              @PerBa any update?

              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
                7/8
                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