Read the statement by Michael Teeuw here.
MMM-PIR-Sensor-Lite modification
-
Re: PIR problem
I have also been experiencing similar problems with my PIR sensor since upgrading to Bullseye. After trying numerous modules, I inquired about suggestions for updated modules that have been known to work with Bullseye and posted a request in the forum (https://forum.magicmirror.builders/topic/17810/pir-sensor-for-raspbian-11). It seems that many have chosen to go with the MMM-PIR-Sensor-Lite module, so I will pose my question here.
My PIR sensor appears to function properly and after the standby timeout, the HDMI output will turn off (I am using the ‘xrandr’ command type). However, this results in my monitor detecting a missing signal and it will put up a “No Signal” indication on the screen. Further, after a certain time, it will turn the monitor OFF, which requires that I need to push buttons in order to turn it back on again. My understanding is that I need to use HDMI CEC commands in order to instruct the monitor to turn off, which will prevent the “No Signal” indication from appearing. This was a completely working feature in my Magic Mirror prior to upgrading to Bullseye.
I used the EXT-Pir and EXT-Screen modules (https://wiki.bugsounet.fr/) in the past and they were able to accomplish the task. However, I don’t have enough skill to examine the code to determine how the commands are being sent to turn off my monitor. The EXT-Screen module simply required that I choose a mode (mode:4 - use HDMI CEC) in the configuration and it successfully controlled the monitor. What I would need is to have these commands implemented in a PIR sensor module, or I would need some guidance on how to implement these codes in the MMM-PIR-Sensor-Lite module.
Any insight you might have would be appreciated…
-
@Freddy_boy on the cec side
from the raspberry pi forums
https://forums.raspberrypi.com/viewtopic.php?t=348779to add to the module, edit the node_helper.js and change the command for one of the modes to use the cec commands (Once u get them to work)
I can’t get cec to work on my pi3… works ok on my pi 4…
(haven’t tried the latest kernel version of pi os)if u want to add another mode to pir-sensor-lite
in the modulename.js change
if(!['vcgencmd', 'xrandr', 'xset'].includes(this.config.commandType)) {
that to include whatever string you use for the cec command type
and then in the node_helper.js
switch(this.config.commandType) { case 'vcgencmd': exec("/usr/bin/vcgencmd display_power 1", null); break;
change the case tot the new string you picked and then change the exec command to the cec command
note:
there are two places to change… 1 to turn on the monitor, one to turn off, same commandType, different exec commands
OR post an issue to the module author asking them to provide the support…
OR make the change on your own fork of the module and submit back to the author as an enhancement.
-
Ok. I think I understand the strategy here. I will just need to figure out the proper HDMI CEC code that I need. Thanks. I’ll let you know how things progress…
-
@Freddy_boy you could copy it out of the ext screen module which worked… (if u still have the older repo installed somewhere)
thats what I did when I was testing PIR and other sensors a year or so ago
-
I attempted to run the CEC commands manually, but that doesn’t work. I just keep getting active source unknown error message. Unfortunately, I don’t have the original EXT-Screen module because I attempted to perform an update on the module, so I only have the updated module. Perhaps the updated module has updated code? But I don’t know where to look for the required commands. I’ve looked at the EXT-Screen.js file and the node_helper.js file and I don’t see anything that looks like a CEC command. Also, the files are difficult to view, as the entire code is written on a single line, so you need to search for text strings to find anything.
-
@Freddy_boy said in MMM-PIR-Sensor-Lite modification:
Also, the files are difficult to view, as the entire code is written on a single line, so you need to search for text strings to find anything.
yes, he has minified the code to prevent others using it… or learning form it…
does this work to list the cec devices?
echo 'scan' | cec-client -s -d 1
-
From SSH connection:
pi@raspberrypi:~ $ echo ‘scan’ | cec-client -s -d 1
opening a connection to the CEC adapter…
requesting CEC bus information …
CEC bus information===================
device #1: Recorder 1
address: 1.0.0.0
active source: no
vendor: Pulse Eight
osd string: CECTester
CEC version: 1.4
power status: on
language: engcurrently active source: unknown (-1)
pi@raspberrypi:~ $ -
Update: I’m not sure how it happened, but I believe that my monitor had the controls disabled. It is an LG monitor using Simplink, and when I enable it, I can now see the device:
pi@raspberrypi:~ $ echo ‘scan’ | cec-client -s -d 1
opening a connection to the CEC adapter…
requesting CEC bus information …
CEC bus information===================
device #0: TV
address: 0.0.0.0
active source: yes
vendor: LG
osd string: TV
CEC version: 1.3a
power status: on
language: engdevice #1: Recorder 1
address: 1.0.0.0
active source: no
vendor: LG
osd string: CECTester
CEC version: 1.3a
power status: on
language: engcurrently active source: TV (0)
However, when I attempt to turn OFF the monitor using the CEC control commands, it doesn’t seem to work. The commands appear to be working (ie. no error messages returned), but the monitor remains ON when I issue the standby command. I also use the ‘power’ command to check the status of the monitor, and it confirms that it is ON.
pi@raspberrypi:~ $ echo ‘pow 0.0.0.0’ | cec-client -s -d 1
opening a connection to the CEC adapter…
power status: on
pi@raspberrypi:~ $ echo ‘standby 0.0.0.0’ | cec-client -s -d 1
opening a connection to the CEC adapter…
pi@raspberrypi:~ $ echo ‘pow 0.0.0.0’ | cec-client -s -d 1
opening a connection to the CEC adapter…
power status: on
pi@raspberrypi:~ $ -
I have also tried:
sudo echo ‘standby 0.0.0.0’ | sudo cec-client -s -d 1but got the same result…
-
@Freddy_boy ok, I have a CEC tv which I can turn OFF, but not back on…