An alternative using a module

Using a module to allow interaction between external applications and the mirror.


Ladies, and gentlemen.  It seems that I have gone too fast in my conclusions.  I was under the impression that the only way to allow external interaction to the mirror is by adjusting the core code.  That’s why I did some adjustments to the core code in this article.

Turns out I was wrong.  And i’m happy to admit it really.  The kind people at the magic mirror community pointed out to me that it might be better to create my own module to allow mirror commands.

Check out the forum for great support!

Someone pointed me to an existing mirror module, which you can find in the URL below.

Thank you very kindly for that!

Let’s check this out.  First get it from GitHub into my “modules” subfolder of the smart mirror root folder.

git clone

I’ll be adjusting the mirror configuration.  Kick out the compliments module, and add the new one.  And restart the mirror.

Schermafbeelding 2017-01-22 om 10.54.54.png

The documentation of the module states that the only thing to do is send a message with the following syntax :


Let’s try.  Start a browser and …

Schermafbeelding 2017-01-22 om 10.54.21.png

Yeeha.  A popup.

Schermafbeelding 2017-01-22 om 10.54.29.png

And a log in the middle of the screen.

Schermafbeelding 2017-01-22 om 10.54.34.png

How wonderfully easy is this.

Now to check out how this works, and how we can adjust it to make the same hide and show functionality as in the core adapting solution.

First, some reading in the Magic mirror module documentation.  I should have done this with some more attention earlier, but hey… sometimes I want to go too fast.

In here, the concept of node helpers is discussed. And it is what it is : a helper .js file where some node.js code can be created to support your module.

I found an example of hiding mirror elements in the following :

By the way : this is a module allowing voice control!  Something to check out further, but as far as I can see it only takes a few mirror related commands.  The advantage of using Alexa is also there of course (you can ask here whatever you want).  It might be something to add 2 wake words like “alexa” and “mirror” or something, but there are pro’s and cons in here.  But I digress.

I’ll be adjusting the MMM-syslog code, in the place where a message is received, and is being display I’ll add my own temporary test code:

Schermafbeelding 2017-01-22 om 11.45.10.png

Just check for a different notification, and execute the code the hide the modules.

Next, adjust the node helper with another express routing as below :

Schermafbeelding 2017-01-22 om 11.45.44.png

It basically almost copies the existing code, but instead of sending a message in the notification, it sends the “hide” command.  And that’s it.  No core adjustments needed anymore.

Why is this working?  Well, the combination of the ability to access this.ExpressApp in the node helper, the MM availability in the module and the native notification features make everything possible that was possible using the core adapting solution.


Now, to hook things up again, so it can be used in conjunction with the debug hub.  I’ve commented away the app.get function in server.js.  Just to make sure there are no 2 handlers for the same routings.  And added this to the node helper of the MMM-syslog module :

Schermafbeelding 2017-01-22 om 12.59.56.png

Adding this to MMM-Syslog should do the trick.

Schermafbeelding 2017-01-22 om 13.00.15.png

And here’s the result.


I will be moving forward with this approach, as I think it has more potential.  I won’t be demonstrating it in this article, but I’ll comment away the core code I added in this article.

Thanks again to the community to point this out.  Keep you posted!




One thought on “An alternative using a module”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s