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

Notifications help

Scheduled Pinned Locked Moved Solved Troubleshooting
7 Posts 3 Posters 865 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.
  • S Offline
    sdmydbr9
    last edited by Feb 12, 2023, 3:59 AM

    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 B 2 Replies Last reply Feb 12, 2023, 4:18 AM Reply Quote 1
    • S Offline
      sdmydbr9 @sdetweil
      last edited by Feb 13, 2023, 10:36 AM

      @sdetweil
      Got it thanks

      1 Reply Last reply Reply Quote 0
      • S Offline
        sdetweil @sdmydbr9
        last edited by Feb 12, 2023, 4:18 AM

        @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

        How to add modules

        learning how to use browser developers window for css changes

        S 1 Reply Last reply Feb 12, 2023, 5:06 AM Reply Quote 0
        • B Offline
          BKeyport Module Developer @sdmydbr9
          last edited by Feb 12, 2023, 4:34 AM

          @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 Feb 12, 2023, 5:10 AM Reply Quote 0
          • S Offline
            sdmydbr9 @sdetweil
            last edited by Feb 12, 2023, 5:06 AM

            @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 Offline
              sdmydbr9 @BKeyport
              last edited by Feb 12, 2023, 5:10 AM

              @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 Feb 12, 2023, 3:48 PM Reply Quote 0
              • S Offline
                sdetweil @sdmydbr9
                last edited by Feb 12, 2023, 3:48 PM

                @sdmydbr9 I replied on discord

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                S 1 Reply Last reply Feb 13, 2023, 10:36 AM Reply Quote 0
                • S Offline
                  sdmydbr9 @sdetweil
                  last edited by Feb 13, 2023, 10:36 AM

                  @sdetweil
                  Got it thanks

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