Read the statement by Michael Teeuw here.
MMM-Motion-Detection {fixed monitor on/off} tvservice --> vcgencmd
-
Re: [MMM-Motion-Detection] Motion Detection through PiCam or USB Webcam
I have limited knowledge of programming and here I was trying to setup a magic mirror with a motion sensor. I looked into PIR sensors but the glass was too reflective for them to function properly, so I decided on using a USB webcam as a motion sensor instead. Only problem was that MMM-Motion-Detection had almost no documentation, and once I finally got the module ‘functioning’, the monitor would turn on but wouldn’t display anything. Forcing me to reset the RPi and monitor to finally get it to display again properly. After researching for hours, the only mention of the problem I was encountering was a couple short sentences from a guy, gismo2006, who had solved the same issue but was asking a completely different question in the post
"I see only a black page. So after i changed the order to activate and deactivete from ‘tvservice’ to ‘vcgencmd display power 1’… "
There we go! If only I can figure out wtf that means! More googling and everyone’s saying ‘vcgencmd’ is wayyyyy better than tvservice. Sweet! So with my vast knowledge of programming how the f*** do I do that? Figured if I fired up every single MMM-Motion-Detection module file with notepad++ I could just ctr+f ‘tvservice’ every doc until it pops up… and it totally F’ing worked! Found it in the node_helper.js!
activateMonitor: function () { if (this.config.turnOffDisplay) { // Check if hdmi output is already on exec("/opt/vc/bin/tvservice -s").stdout.on("data", function(data) { if (data.indexOf("0x120002") !== -1) exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null); }); } }, deactivateMonitor: function () { if (this.config.turnOffDisplay) { exec("/opt/vc/bin/tvservice -o", null); } },
Now more confusion! It seems to be executing a file? I can’t think of any other reason to use a directory file listing (seriously shooting into the dark). So I directly plug-in tvservice -o into the command prompt, without the file directory, and it turned off my monitor! OH YEAH BOY! I’M AN 3LITe C0D3R!!! Finally, I’m honing in on the answer, after countless hours of desperately searching. Now it’s time for the fireworks; pi@raspberrypi:~ $ tvservice -p.!! …my monitor starts turning on, my palms are sweaty from the anticipation of finally being able to change my clothes after two miserable days of blankly staring into the monitor.
The friendly reminder on the screen that HDMI 2 was the signal source had me jumping in ecstasy!
Then nothing…
The screen was clearly on, but a hazy, black background was all I could see.
It felt like I was looking into my own soul.Okay, so it’s obviously this tvservice function that is ruining my life. This was suppose to be a fcking gift, now it’s become a fcking obsession. A fcking obsession and a fcking two month late gift. At this point I’m literally losing calcium in my bones. Might as well pop a bottle and start chain-smoking cigarettes.
So, the exec array obviously runs tvservice on/off functions, I know what each command does; Maybe I can just swap out those commands with similar0 vcgencmd commands without having to enter some weird file directory looking command
}, activateMonitor: function () { if (this.config.turnOffDisplay) { // Check if hdmi output is already on exec("vcgencmd display_power 1").stdout.on("data", function(data) { if (data.indexOf("0x120002") !== -1) exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null); }); } }, deactivateMonitor: function () { if (this.config.turnOffDisplay) { exec("vcgencmd display_power 0", null); } },
BINGO! My pants are instantly sopping wet, but was worth it because… I’M THE KING OF THE FCKING WORLDDDDDDDDD!!! 1337 BITCHES!!! 1337 C0D3R!! I DID IT HAHAHHAHAHHAHAHAHHHAHAH NO MORE WILL I BE SHAMED. VINNY VINNY WHATEVER HAHAHAHAHHAHA
Now if only I can get the mic to work…
tl;dr: Navigate to your node_helper.js and replace:
activateMonitor: function () { if (this.config.turnOffDisplay) { // Check if hdmi output is already on exec("/opt/vc/bin/tvservice -s").stdout.on("data", function(data) { if (data.indexOf("0x120002") !== -1) exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null); }); } }, deactivateMonitor: function () { if (this.config.turnOffDisplay) { exec("/opt/vc/bin/tvservice -o", null); } },
with
activateMonitor: function () { if (this.config.turnOffDisplay) { // Check if hdmi output is already on exec("vcgencmd display_power 1").stdout.on("data", function(data) { if (data.indexOf("0x120002") !== -1) exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null); }); } }, deactivateMonitor: function () { if (this.config.turnOffDisplay) { exec("vcgencmd display_power 0", null); } },
Probably not perfect, but it does the trick.
-
Hi,
I found your post.
I have/had several problems with tvservice. So I decide to google about one or two years ago. Then I found the vcgencmd and everytime there was spoken about tv serve i use vcgencmd and everything works fine ;-)
To find out what I mean, you could just send me a pn :-D
greets gismo2006
-
@gismo2006 Hey, honestly if it wasn’t for the fact that you mentioned changing tvservice to vcgencmd I’d never have figured it out! Your brief commend put me on the right path to getting everything working, thank so you much!! If I run into any problems with vcgencmd in the future I’ll be sure to pm you :)