Read the statement by Michael Teeuw here.
Help with MMM-PIR-Sensor tvservice logical evaluation
-
Can someone help shed some light on this piece of code in the MMM-PIR-Sensor module? In the node_helper.js there is:
// 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);I understand what it is doing. It is checking if the monitor is in standby [TV is off] and if so then it turns it on. This bit of code also executes when the monitor is on though which is the part that I am having trouble with. I understand that 0x120002 is what tvservice reports when the monitor is off. I don’t understand the
!== -1Any help? I would like to change the logic so it doesn’t execute that line when the monitor is on (0x12000a)
-
@orayoflighto if there is no occurence of the string
0x120002, the methodindexOfreturns-1. So he checks if the string0x120002is part of the variable data. -
I figured it out. There are missing brackets for the if statement. In node_helper.js:
From:
if (data.indexOf("0x120002") !== -1) exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null);To:
if (data.indexOf("0x120002") !== -1){ exec("/opt/vc/bin/tvservice --preferred && chvt 6 && chvt 7", null); }
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login