Read the statement by Michael Teeuw here.
My first module
-
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
-
@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"); } },
-
@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…
-
@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
-
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
-
@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
-
Ok, Thank you for your help. I will try myself to go this next step…
-
@gismo2006 https://github.com/fewieden/MMM-voice/blob/f9eb4cd4bde5c64ef894e8625250c4092aa0d4a7/node_helper.js
line 10, 23-31, 213 will help you
-
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
-
@gismo2006 no worries, if you come up with more questions don’t hesitate to ask