@pauabaer sure, however, I have other projects to work on so I rather focus on them. I don’t have that much knowledge in javascipt either. (I do have some knowledge in other language though). When I do stuff it’s a lot a trial and error until that work (even for the tiny bit of code I made in this post required some research from me. Not a lot of it… but some. I never used the moments() function before)
This is your opportunity to gain knowledge.
Read the statement by Michael Teeuw here.
Posts
-
RE: Is there a way to show specific compliments on specific dates?
-
RE: Is there a way to show specific compliments on specific dates?
@pauabaer Na, perhaps you can make it youself ;)
It’s not that hard, just read about array and function in javascript.
The idea is :
-You creat a function.
-You creat a variable in the config part. the variable should be an array. The easiest thing would be to make it an array of dictionnaries. So you can put a date and a message in each ones.
-Inside the function you stock the value of moment().format(‘MMM D’) in a variable
-Then you make a for that iterate on each element of the array an compare the value of moment().format(‘MMM D’) that you just got to the date part of each dictionary.
-If there is a match, you return the associate message. if not, you just return an empty string.
-In the getDom function you call that function instead of the randomComplimentAnd you should be fine.
And hey, if you succeed you’ll could be proud to say you did a module yourself (sort of) ! -
RE: Is there a way to show specific compliments on specific dates?
@pauabaer for the config file, you can just use the default one. we didn’t change much with that code.
To add another date, just add as manyelse if ()
statement as needed. This isn’t a pretty solution but it will work.// Override dom generator. getDom: function() { var complimentText = this.randomCompliment(); if (moment().format('MMM D') == 'Apr 27') { this.show(); complimentText = "Happy birthday" } else if (moment().format('MMM D') == 'Apr 28') { this.show(); complimentText = "Happy 28th day" } else this.hide(); var compliment = document.createTextNode(complimentText); var wrapper = document.createElement("div"); wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright"; wrapper.appendChild(compliment); return wrapper; },
It’s not a pretty solution. I could made it prettier by creating a separate function with a while abd set a variable in the config section so you can add as many date as you want by editing the config.js. But I’m lazy so … yeah, not pretty solution.
-
RE: npm start error?
@longod I don’t own a pi zero but I have few question.
- Were you on the MagicMirror folder when you did the npm start ?
- Were you directly on the pi using a usb keyboard (or equivalent) or were you on ssh ?
If you were on the MagicMirror folder and you were directly on the pi I don’t know what the issue could be.
If you wasn’t on the MagicMirror folder npm start won’t work.
If you accessed your pi by ssh you need to useDISPLAY=:0 npm start
command instead of npm start because graphical application need to know where they should be open. DISPLAY:0 mean the host machine (your pi) -
RE: 3 different Alexa modules, which one is the best?
@borrigan Try to let “default” as an input device rather than myTest. The default thing will be in charge to call myTest itself (I think putting myTest directly doesn’t work for some weird reason I don’t now about)
Do you hear the “hello” when you run the script ?
If you still have the error after using the default, then ty to change you input handler from sox to vlc.I don’t think that’s related but at this point trying stuff might be the right thing x) Maybe that will fix it. -
RE: Is there a way to show specific compliments on specific dates?
@CyanKali It should have replace all compliment. At that particular date.
well, yesterday was the 26 right ? you let the 27 so I guess it just wasn’t the rigth date to activate.
Try changing the date. (well, today must be the 27 so It should work today ahah).@pauabaer you could use the compliment module. add the thing I had and then go on the config.js file and replace all the compliments by empty strings so it will display nothing when not the date
{ module: "compliments", position: "lower_third", header: "", config: { compliments: { anytime: [ "" ], morning: [ "" ], afternoon: [ "" ], evening: [ "" ] } } },
Or you could change the code so the module hide itself when the date isn’t right
// Override dom generator. getDom: function() { var complimentText = this.randomCompliment(); if (moment().format('MMM D') == 'Apr 27') { this.show(); complimentText = "Happy birthday" } else this.hide(); var compliment = document.createTextNode(complimentText); var wrapper = document.createElement("div"); wrapper.className = this.config.classes ? this.config.classes : "thin xlarge bright"; wrapper.appendChild(compliment); return wrapper; },
-
RE: Is there a way to show specific compliments on specific dates?
I don’t know if there is one but you could very simply modify the compliment module to do so.
just addif (moment().format('MMM D') == 'Apr 27') complimentText = "Happy birthday"
to replace compliment by happy birthday on that date.
In the getDom function undervar complimentText = this.randomCompliment();
and you should good to go. just change the date to match your birthday. (it’s always the first 3 letter of the month. the first letter as to be capital. the number is 1 to 31 (not 01 or 02 or 03 etc… directly 1 or 2 or 3 …)You can add more if to add more specific message en specific date. you could also creat a new variable in the config array and compare the moment().format directly to that variable so you can set it up from the config file. You could even make that variable an array of date and encapsulate the if into a for and compare each date of that array to the moment().format so you can add as many date as you want.
-
RE: 3 different Alexa modules, which one is the best?
@johnnyboy Yes, But it’s not your fault. I have read an entire very long thread about mirror mirror on the wall (and maybe some others, I don’t remember if all the information were on the same spot or not) and it seem that one guy talked about trying that (changing the region) and the creator of the module himself didn’t knew Ireland was possible. But he did point out in which file the region thing was. (it wasn’t had to find though).
So I do think he meant that “that one ‘must’ be in the us-east” because he didn’t knew there was another option.
And he didn’t changed his tutorial to reflect that. (I’m guessing because he wasn’t able to test this way itself. Or maybe he wasn’t willing to) -
RE: 3 different Alexa modules, which one is the best?
@johnnyboy I struggle because of this @johnnyboy at first. But the lambda service is working both with us and ireland (west-eu or eu-west. don’t remember exactly now).
I end up have skill that was working. On the amazon interfaces anyway by choosing that instead of us. (even though I’m in france. I had no error anymore on the amazon test aera)
I had to change the hard coded region in the code though (easy fix).
I think I had no more error at the end (don’t remember for sure). But nothing was happening when I talked (maybe it was again a microphone issue. Not really sure about that)
I also did not understood how to use thenpm start dev
correctly at that time so maybe I would be able to do a better job at finding the issue now.
Maybe I try today, maybe I never try again. we’ll see (it’s not my raspberry pie I using so I am limited in when I can use it. So I rather do what I am ask to first before trying again) -
RE: turning monitor on by incoming call?
@timog What do you mean ? there are two different module. So they aren’t link for sure. That’s where the “notification” system come into play.
I saw two type of notification in the maagic mirror modules.- The socket notification: It’s a way to “send” data (payload) to the node_helper.js of that module and for the node_helper to send back data as well. You cann’ot reach other modules with it. You can just tell your node helper to do some things for you (because node_helper is node js and not just js)
it allow you to do things you can’t normally do. Such as open and read a file). you send a socket notification by using the functionthis.sendSocketNotification(notification, payload);
wherenotification
is a string, for example “TOTO” or “Hello, my name is slam shady”. Andpayload
is any variable you want to transmit. it’s common tu use a dictionary with because it allow you to send multiple variable at once .
A dictionary is a list of key associate with value separate with comma encapsulate in {};
for examplethis.sendSocketNotification("LUNCH", {drink: water, dish: sandwich});
would be a valid synthax.
This will send a notification lunch and the associate payload. It will be get by a function “socketNotificationReceived” that look like this:
socketNotificationReceived: function(notification, payload) { if (notification === "LUNCH") { Log.log("I going to drink" + payload.drink + " and I going to eat a " + payload.dish); } },
- the normal notification. That’s what you want, that allow you to send notification to OTHER module with an associate payload. sending notification work exactly like socket notification but you don’t write socket. so it would be more like
this.sendNotification("LUNCH", {drink: water, dish: sandwich});
and it isn’t get by socketNotificationReceived but bynotification received
notificationReceived: function(notification, payload, sender) { Log.log("I received a notification from " + sender + " !"); if (notification === "LUNCH") { Log.log("I going to drink" + payload.drink + " and I going to eat a " + payload.dish); } },
The difference is that the received function have an additional argument “sender” that is the name of the module you got the notification from.
So, what you want to do is identify where in the code the call is detected. When you do, you want to use sendNotification to tell MMM-PIR-Sensor that a call is incomming. as an example:
this.sendNotification("CALL INCOMMING", {});
and in the MMM-PIR-Sensor you want to catch that. if the MMM-PIR doesn’t have a notification received creat one.notificationReceived: function(notification, payload, sender) { if (notification === "CALL INCOMMING") /*you can also add a condition to check if the sender is MMM-FRITZ-Box-CallMonitor if you want to be sure that if another module send you a similar notif yu won't react*/{ // call the function you want } },
if it already have a notificationReceived function just add the if inside.
That’s where you detective work continue. You need find what’s happen when the captor detect you. What does he do ? you need to call the same function it call. If the function is in the node_helper, you will need to send a socket notification and to the node helper (again, you can choose whatever name for the notification). And add an if in the socketNotificationReceived of the node_helper or add one if none exist.
then you can call the same function the detection does.
That’s involved a little trial and error. You could try to send a socketNotification to the node_helper, catch it and send back a socketNotification USER_PRESENCE from the node_helper to the main js like soself.sendSocketNotification("USER_PRESENCE", true);
. Maybe that’s all there is to it.
Or maybe you just need to send a socketNotification SCREEN_WAKEUP from the main js to the node_helper. like sothis.sendSocketNotification("SCREEN_WAKEUP", {});
Bref, maybe the screen_wakeup if enough, maybe you really need to fake human presence but sending the user_presence, maybe there is another function to call. Try a bunch of stuff.
Remember, the idea is to send a global notification that a call is there with sendNotification. catch it in pyr sensor with socketNotificationReceived. Then call the right function. If the function is already in the MMM-PIR-Sensor.js then just call it. and if it is in the node_helper send a socketNotification.
My best bet is that you need to either send directly the SCREEN_WAKEUP socketNotification from MMM-PIR-Sensor.js to node.helper.js or send a random notification that you choosed from the MMM-PIR-Sensor.js to node.helper.js and then send back a USER_PRESENCE notification with the payload true.Hopefully it was clear enough. I know it’s hard to understand that kind of stuff when you never did it before (Even though I had experience in coding in other languages, I did not had the experience in js / node js / magicmirror so I struggle at first myself)
- The socket notification: It’s a way to “send” data (payload) to the node_helper.js of that module and for the node_helper to send back data as well. You cann’ot reach other modules with it. You can just tell your node helper to do some things for you (because node_helper is node js and not just js)