MagicMirror² v2.13.0 is available! For more information about this release, check out this topic.

turning monitor on by incoming call?

  • I’m using the MMM-PIR-Sensor, so the monitor is turning off after a short time.

    Is there any chance to turn the monitor on by an incoming call notification (MMM-FRITZ-Box-CallMonitor) and off again after a short time?

    I would like to implement it in the PIR-module (turning on and off by notification).

  • Never tryed those module but you should open the code, find where MMM-FRITZ-Box-CallMonitor detect a call (I beleive it’s on the socketNotificationReceived function).
    Then you should identify which function is called when the sensor detect you in the MMM-PIR-Sensor.
    Then you can add a this.sendNotification("THE_NAME_YOU_WANT", {}) in the MMM-FRITZ-Box-CallMonitor side and a

    if (notification === "THE_NAME_YOU_WANT") {
      //call the function that the sensor thing call

    And it should work.
    I can’t help you more than that because I do not own those sensors.
    Good luck

  • This post is deleted!

  • @romain Thank You! That was already very helpful.
    I tried it, but i think the MMM-FRITZ-Box-CallMonitor got no link to the functions of MMM-PIR-Sensor(?).
    Is there a command to refer or do i have to copy & paste all functions?

  • @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 function this.sendSocketNotification(notification, payload); where notification is a string, for example “TOTO” or “Hello, my name is slam shady”. And payload 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 example this.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 " +;
    • 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 by notification 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 " +;

    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 so self.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 so this.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)

  • Project Sponsor Module Developer

    @romain said in turning monitor on by incoming call?:

    Hopefully it was clear enough. I know it’s hard to understand that kind of stuff when you never did it before

    It was wonderfully clear. I can barrel my way through some simple coding without really understanding how or why it’s working (or not working). Thanks for helping me to understand a little better.