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

My first module

Scheduled Pinned Locked Moved Development
10 Posts 2 Posters 5.3k 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 Oct 21, 2016, 8:38 PM

    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

    S 1 Reply Last reply Oct 21, 2016, 8:47 PM Reply Quote 0
    • S Offline
      strawberry 3.141 Project Sponsor Module Developer @gismo2006
      last edited by Oct 21, 2016, 8:47 PM

      @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 Oct 21, 2016, 8:54 PM Oct 21, 2016, 8:54 PM

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

        S 1 Reply Last reply Oct 21, 2016, 8:56 PM Reply Quote 0
        • S Offline
          strawberry 3.141 Project Sponsor Module Developer @gismo2006
          last edited by Oct 21, 2016, 8:56 PM

          @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 Oct 21, 2016, 9:12 PM

            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

            S 1 Reply Last reply Oct 21, 2016, 9:13 PM Reply Quote 0
            • S Offline
              strawberry 3.141 Project Sponsor Module Developer @gismo2006
              last edited by strawberry 3.141 Oct 21, 2016, 9:14 PM Oct 21, 2016, 9:13 PM

              @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 Oct 21, 2016, 9:16 PM

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

                S 1 Reply Last reply Oct 21, 2016, 9:20 PM Reply Quote 1
                • S Offline
                  strawberry 3.141 Project Sponsor Module Developer @gismo2006
                  last edited by Oct 21, 2016, 9:20 PM

                  @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 Oct 21, 2016, 9:34 PM

                    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

                    S 1 Reply Last reply Oct 21, 2016, 9:35 PM Reply Quote 0
                    • S Offline
                      strawberry 3.141 Project Sponsor Module Developer @gismo2006
                      last edited by Oct 21, 2016, 9:35 PM

                      @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
                      • 1 / 1
                      1 / 1
                      • First post
                        7/10
                        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