So that my MagicMirror is only switched on when I actually use it, I have configured a small automation using NodeRed.
The screen is only switched on if movement is detected.
The screen itself is switched on and off using the “vcgencmd” command. (More information here: https://www.raspberrypi.org/documentation/raspbian/applications/vcgencmd.md)
With the following NodeRed code you can switch the screen connected to the RaspberryPi (on which NodeRed runs) on and off.
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/en/sicherheitshinweise/
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and shop via this link, Nerdiy.de receives a commission from the online shop or provider concerned. The price doesn't change for you. If you do your purchases via these links, you will support Nerdiy.de in being able to offer further useful projects in the future. 🙂
So that you can install new nodes and import NodeRed code, NodeRed should of course already be installed.
How to prepare a RaspberryPi and then install NodeRed on it is described in the following articles.
- RaspberryPi – Setup for nerdiys!
- RaspberryPi – The first configuration!
- RaspberryPi – Control the RaspberryPi via SSH
- NodeRed – Installation of NodeRed on the RaspberryPi
- NodeRed – Installing new nodes
- NodeRed – Import and export node code
In the following list you will find all the parts you need to implement this article.
Log in to the NodeRed configuration interface
Before you can edit your NodeRed configuration you must - if activated - first log in to the NodeRed configuration interface.
By importing the NodeRed code below, the view shown below will be added to your dashboard. For this to work, you should have already installed and configured the dashboard node. You can find information about this in the following article.
Information on how to import the NodeRed code into your NodeRed instance is summarized in the following article.
In the view shown on the left you can see which elements will be added to your dashboard.
- A “turn off screen” button
- A “turn on the screen” button
- A “refresh screen status” button
- The history of switching on and off times
- A button that signals the monitor status
You can find the NodeCode in the Nerdiy Git repository at:
More articles on NodeRed
Further articles on the subject of NodeRed including examples can be found under the following link.
Have fun with the project
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂