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

Need help understanding "sendNotification"

Scheduled Pinned Locked Moved Unsolved Troubleshooting
9 Posts 3 Posters 2.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.
  • M Offline
    MWel1977
    last edited by Jan 11, 2019, 3:51 PM

    I’m in need of help understanding how this “sendNotification” items works from one module to the other.
    Does a module sends it in general or is it targeting a specific other module?
    And if it is sending the notification in general to all modules how must I configure the module that actualy needs to do something with those notifications?

    I would like to use MMM-Swipe (That uses 2 HC-SR04 units) to controle MMM-Pages and MMM-Page-Indicator.
    I have the Pages modules already installed. And I’m creating a test setup with the 2 ultra sonic sensors this weekend to test the workings.
    But I have no clue what file I need to alter so that when I “swipe” across the 2 sensors the pages actualy change.

    Looking at the readme-file that came with the Swipe module it says:

    This module will use the sendNotification(notification, payload) to send:
    notification = 'MOVEMENT'
    payload = 'Swipe Left', 'Swipe Right', or 'Press'
    Please use as appropriate in your module using notificationReceived(notification, payload, sender)

    While in the Pages.js file I read that that module listens to the notifications:

    Handles incoming notifications. Responds to the following:
    ‘PAGE_CHANGED’ - Set the page to the specified payload page.
    ‘PAGE_INCREMENT’ - Move to the next page.
    ‘PAGE_DECREMENT’ - Move to the previous page.
    ‘DOM_OBJECTS_CREATED’ - Starts the module.
    ‘QUERY_PAGE_NUMBER’ - Requests the current page number

    I was hoping to find something that looks like:
    if payload = then do this…

    Is there someone willing to have a look and tell me what to configure?
    I could look all day at the code and still don’t get it.

    1 Reply Last reply Reply Quote 0
    • S Away
      sdetweil
      last edited by Jan 11, 2019, 3:54 PM

      sendNotification is a broadcast. every other module gets it…

      they get

      the sender, the identifier, and the payload.

      the receiver must decide what to do with the information, if anything

      Sam

      How to add modules

      learning how to use browser developers window for css changes

      S 1 Reply Last reply Jan 11, 2019, 4:02 PM Reply Quote 0
      • S Away
        sdetweil @sdetweil
        last edited by sdetweil Jan 11, 2019, 4:04 PM Jan 11, 2019, 4:02 PM

        @sdetweil so.
        MMM-Swipe says

         'Swipe_left'
        

        but MMM-Pages is listening for

        'PAGE_CHANGED' - Set the page to the specified payload page.
        'PAGE_INCREMENT' - Move to the next page.
        'PAGE_DECREMENT' - Move to the previous page.
        

        so, some other module needs to translate. I don’t know of a module that would do this…
        receiveNotiication Swipe_Left, and then sendNotification PAGE_DECREMENT (after checking to see if above page 0 I would assume).

        Sam

        How to add modules

        learning how to use browser developers window for css changes

        ? 1 Reply Last reply Jan 11, 2019, 4:33 PM Reply Quote 1
        • ? Offline
          A Former User @sdetweil
          last edited by A Former User Jan 11, 2019, 4:39 PM Jan 11, 2019, 4:33 PM

          @sdetweil said in Need help understanding "sendNotification":

          so, some other module needs to translate. I don’t know of a module that would do this…

          MMM-NotificationTrigger can do that notification translation between modules.

          receiveNotiication Swipe_Left, and then sendNotification PAGE_DECREMENT (after checking to see if above page 0 I would assume).

          {
            module: "MMM-NotificationTrigger",
            config: {
              triggers:[
                {
                  trigger: "Swipe_Left",
                  fires: [
                    {
                       fire: "PAGE_DECREMENT"
                    }
                  ]
                }
              ]
            }
          }
          
          S 1 Reply Last reply Jan 11, 2019, 5:08 PM Reply Quote 3
          • S Away
            sdetweil @Guest
            last edited by Jan 11, 2019, 5:08 PM

            @sean thanks for that !.. great info… amazing the contribution around this platform…

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • M Offline
              MWel1977
              last edited by Jan 11, 2019, 8:02 PM

              @sdetweil @Sean THANK YOU SOOOOOO MUCH!!!
              I’ll get right on it. Just finished my sensor setup with some small pieces of plywood. Now to fire up my pi 3A with the Pi touchscreen…install that notification trigger module and start testing!

              I do however have a question about the modules listening to the “payload”.
              Isn’t it better to have a “translator” build in a module when it can recieve notifications? Or to use a standard string (string01, string02, etc,) it listens to unless the user defines otherwise in the config.js file?

              ? 1 Reply Last reply Jan 11, 2019, 8:04 PM Reply Quote 0
              • ? Offline
                A Former User @MWel1977
                last edited by Jan 11, 2019, 8:04 PM

                @mwel1977
                NotificationTrigger also has payload translator, sender filter, etc.

                M 1 Reply Last reply Jan 11, 2019, 8:32 PM Reply Quote 0
                • M Offline
                  MWel1977 @Guest
                  last edited by Jan 11, 2019, 8:32 PM

                  @sean Thanks! :smiling_face_with_open_mouth_smiling_eyes:
                  I’m just about ready setting the config for the Swipe module.
                  Then is’t the Notifications turn to be configured.

                  1 Reply Last reply Reply Quote 0
                  • M Offline
                    MWel1977
                    last edited by Jan 11, 2019, 9:14 PM

                    Hmmmmmm… Hooked up the wires to the GPIO pins.
                    configured the Swipe module and hit start to run the MM2.
                    I know … I forgot to configure the Notification module. But I first wanted to see if the sensors worked by displaying the measured distances on the MM2 screen.

                    BUT…on starting the MM2 it freezes! Ctrl+Q, Alt, Esc … nothing works.
                    Only pulling the powercord out of the wallsocket! :crying_face: :crying_face:

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    1 / 1
                    • First post
                      9/9
                      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