MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    SOLVED Notifications help

    Troubleshooting
    3
    7
    171
    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.
    • S
      sdmydbr9 last edited by

      Trying to capture notifications for a module, can anyone tell me what’s wrong with this mai js, my objective for now is to capture the SHOW_ALERT notification and print it in the console log. Here is the mainjs

      Module.register("MMM-11-TTS", {
          start: function() {
              console.log(`Starting module: ${this.name}`);
          },
      
          notificationReceived: function(notification, payload) {
              if (notification === 'SHOW_ALERT') {
                  console.log(`Received notification: ${notification}`);
                  console.log(`Payload: ${payload}`);
              }
          }
      });
      
      
      S BKeyport 2 Replies Last reply Reply Quote 0
      • S
        sdmydbr9 @sdetweil last edited by

        @sdetweil
        Got it thanks

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

          @sdmydbr9 module name = module folder name = module_name.js = register name

          all must match exactly, case matters

          @sdmydbr9 said in Notifications help:

          MMM-11-TTS

          , right?

          only displayed in the dev console log unless u install mmm-logging

          Sam

          Create a working config
          How to add modules

          S 1 Reply Last reply Reply Quote 0
          • BKeyport
            BKeyport Module Developer @sdmydbr9 last edited by

            @sdmydbr9 In my case, it helped me tremendously to have MMM-ViewNotifications installed on my test system, so I could eliminate if it was my code or the notification.

            https://github.com/glitch452/MMM-ViewNotifications

            The "E" in "Javascript" stands for "Easy"

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

              @sdetweil well they match, the folder, the module name and module.js.
              The folder is MMM-11-TTS under the modules directory.
              Under that directory is MMM-11-TTS.js module. I have also specified the config.js to consider this module.
              The contents of the MMM-11-TTS.js posted earlier, is that correct or if there is anything missing, can you please provide me the updated code.

              1 Reply Last reply Reply Quote 0
              • S
                sdmydbr9 @BKeyport last edited by

                @BKeyport I did that and it’s definitely my code, I can see the notification is being sent by the SHOW_ALERT but my module is not able to capture them, I tried different codes and hit mental block now.

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

                  @sdmydbr9 I replied on discord

                  Sam

                  Create a working config
                  How to add modules

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

                    @sdetweil
                    Got it thanks

                    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