First of all: @paviro, many thanks for this module.
I ran into some troubles with the module and thought I should share this (and my solution) here.
Problem:
Without the PIR module, everything worked as it should. After installing the PIR module, everything appeared fine and the (HDMI) monitor switched off after a given amount of time (set via a variable resistance on the sensor itself). Upon motion detection by the PIR, the monitor switched back on but didn’t display anything (I could tell the monitor was on from the backlight). Remote access via ssh was not affected.
In the end, I figured out that this was due to an incorrect setting of the virtual terminal. Typing ‘sudo chvt 9 && sudo chvt 7’ on the remote terminal brought the image back to the monitor connected to the RasPi. After stopping the mirror, modifying the ‘activateMonitor’ function in ‘node_helper.js’ as below, and restarting the mirror, the problem was solved. I hpe this is helpful to others.
Modified section of ‘node_helper.js’:
activateMonitor: function () {
if (this.config.relayPIN != false) {
gpio.digitalWrite(this.config.relayPIN, this.config.relayOnState)
}
else if (this.config.relayPIN == false){
exec("/opt/vc/bin/tvservice -p", null);
exec("/usr/bin/sudo /bin/chvt 9 && /usr/bin/sudo /bin/chvt 7 ", null);
}
PS: There may be more elegant solutions to this, but I my node.js skills are, shall we say, limited?