Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord
    MagicMirror² v2.15.0 is available! For more information about this release, check out this topic.

    UNSOLVED Problem with sending socket notification to module

    Troubleshooting
    3
    8
    912
    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
      PerBa last edited by

      (sorry if this is a re-post, I made a post but couldn’t find it later. Admin can remove this post if needed)

      Hello,
      I’m new to MagicMirror, but I have a problem with two swedish modules:
      MMM-SL-PublicTransport
      MMM-Weather-SMHI-Hourly

      When I’m using them I get the same problem:
      Notifications from module to helper works fine
      Notifications from helper to module does not work (notifications never received).

      I don’t know how to handle this problem. I’ve spent a day with debug logs now, but I’m nowhere close to a solution.

      I would be so happy if someone with knowledge about the communication procedures could look into these two modules and see if they perhaps haven’t been updated after a “core-functionality” change.

      Thanks,
      Per Badlund, Sweden

      S 1 Reply Last reply Reply Quote 0
      • S
        sdetweil @PerBa last edited by

        @PerBa can u show your code in node helper to send?

        Usually the problem is that the ‘this’ pointer is inside some API callback, and not pointing to the node_helper instance.

        ‘this’ is always troublesome.

        That is why many module save ‘this’ at start time in ‘self’ and use ‘self’ instead of ‘this’

        1 Reply Last reply Reply Quote 0
        • P
          PerBa last edited by

          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 Reply Quote 0
          • S
            sdetweil @PerBa last edited by sdetweil

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

            1 Reply Last reply Reply Quote 0
            • P
              PerBa last edited by

              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 Reply Quote 0
              • S
                sdetweil @PerBa last edited by sdetweil

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

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

                1 Reply Last reply Reply Quote 0
                • D
                  dazza120 @PerBa last edited by

                  @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
                    sdetweil @PerBa last edited by

                    @PerBa any update?

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    Enjoying MagicMirror? Please consider a donation!
                    MagicMirror created by Michael Teeuw.
                    Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                    This forum is using NodeBB as its core | Contributors
                    Contact | Privacy Policy