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.

    My first module

    Scheduled Pinned Locked Moved Development
    10 Posts 2 Posters 6.5k Views 2 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.
    • G Offline
      gismo2006
      last edited by

      Hi guys,

      I like to write my first modul. Its a fun modul and didn’t have a reason for anyone. I like to learn to write a module. So I can leaerning a lot I think.

      I have create a folder in modules. Called Sounds I have put it into the config file andy the Mirror stats correctly Juhuuuu! :-) First step reached. :-D But now the Problem… Th module didn’t work. For a first test the only think the modul should do is react on a Message which is send by the Voicecontrolmodul by @alexyak. I have creste for this test a new Hotword calles test. I copy the pmdl file and paste the rigt things into my config file. So far, so good. I think the Problem was the Sounds.js file in my own modul folder Sounds. OHH, before I forget. The Sounds.sh skript is only a shell script and worked fine too. I habe write chmod +x Sounds.sh to create a runable file.

      Here the code, maybe someone can look a this and whre my misstake is :-)

      /* global Module */

      /* Magic Mirror

      • Module: HelloWorld
      • By Michael Teeuw http://michaelteeuw.nl
      • MIT Licensed.
        */

      Module.register(“Sounds”,{

      notificationReceived: function(notification, payload, sender) {
          if (notification === "test"){ 
              exec("sudo /home/pi/MagicMirror/modules/Sounds/Sounds.sh")
      }; 
      
      // Override dom generator.
      getDom: function() {
      	var wrapper = document.createElement("div");
      	wrapper.innerHTML = this.config.text;
      	return wrapper;
      }
      

      });

      greets gismo

      strawberry 3.141S 1 Reply Last reply Reply Quote 0
      • strawberry 3.141S Offline
        strawberry 3.141 Project Sponsor Module Developer @gismo2006
        last edited by

        @gismo2006 you’re missing a { and , (instead of semicolon)

        notificationReceived: function(notification, payload, sender) {
            if (notification === "test"){ 
                exec("sudo /home/pi/MagicMirror/modules/Sounds/Sounds.sh");
            }
        },
        

        Please create a github issue if you need help, so I can keep track

        1 Reply Last reply Reply Quote 0
        • G Offline
          gismo2006
          last edited by gismo2006

          @strawberry-3-141 Thank you for your help. but it didn’t change anything. The problem is the same. Everythink started fine but they didn’t play the Sounds.sh…

          strawberry 3.141S 1 Reply Last reply Reply Quote 0
          • strawberry 3.141S Offline
            strawberry 3.141 Project Sponsor Module Developer @gismo2006
            last edited by

            @gismo2006 try to debug where you’re module is getting stuck like this

            notificationReceived: function(notification, payload, sender) {
                if (notification === "test"){
                    Log.info("test notification received"); 
                    exec("sudo /home/pi/MagicMirror/modules/Sounds/Sounds.sh");
                }
            },
            

            if you don’t see this message in the dev console you propably misconfigured your voice command

            Please create a github issue if you need help, so I can keep track

            1 Reply Last reply Reply Quote 0
            • G Offline
              gismo2006
              last edited by

              Ok I will do what you say.

              Ok I have done

              I have found the Problem. the dev consoles says

              Sounds.js:15 Uncaught ReferenceError: exec is not defined.

              Can i delete the word exec? But I think I have to use it to run the script, right?

              greets gismo

              strawberry 3.141S 1 Reply Last reply Reply Quote 0
              • strawberry 3.141S Offline
                strawberry 3.141 Project Sponsor Module Developer @gismo2006
                last edited by strawberry 3.141

                @gismo2006 yeah you have to create a node_helper to run the script and send a socketnotification t the node_helper and there you can run the script

                Please create a github issue if you need help, so I can keep track

                1 Reply Last reply Reply Quote 0
                • G Offline
                  gismo2006
                  last edited by

                  Ok, Thank you for your help. I will try myself to go this next step…

                  strawberry 3.141S 1 Reply Last reply Reply Quote 1
                  • strawberry 3.141S Offline
                    strawberry 3.141 Project Sponsor Module Developer @gismo2006
                    last edited by

                    @gismo2006 https://github.com/fewieden/MMM-voice/blob/f9eb4cd4bde5c64ef894e8625250c4092aa0d4a7/node_helper.js

                    line 10, 23-31, 213 will help you

                    Please create a github issue if you need help, so I can keep track

                    1 Reply Last reply Reply Quote 0
                    • G Offline
                      gismo2006
                      last edited by

                      Thank you I have looked in the notification Node_helper.js code which was posted in the Voicecontrol post from @tyho. And it works now fine. Now I can learning something new. To grow up my modul and finding a really reason for my module :-D

                      But I like to say Thank you. You helped me a lot. :-)

                      greets gismo

                      strawberry 3.141S 1 Reply Last reply Reply Quote 0
                      • strawberry 3.141S Offline
                        strawberry 3.141 Project Sponsor Module Developer @gismo2006
                        last edited by

                        @gismo2006 no worries, if you come up with more questions don’t hesitate to ask

                        Please create a github issue if you need help, so I can keep track

                        1 Reply Last reply Reply Quote 1

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          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