grenagit / MMM-PIR-Sensor-Lite

[Unmaintained] Magic Mirror Module managing monitor with PIR motion sensor (automatic standby when presence isn't detected)
MIT License
15 stars 10 forks source link

Module it not deactivating the HDMI port #2

Closed Jaunney closed 2 years ago

Jaunney commented 2 years ago

Hi there,

I just set up a new magic mirror, because my old installation had some issues. So I got newest versions of MagicMirror and some modules. I wanted to set up my PIR-Sensor again, but the module I used is outdated. So I choose yours, installed it, no other third party modules yet. The PIR sensor is working also timer and so on, but at the end of the deactivation delay time there is nothing to happen. The timer shows 0s, but the screen stays on. Did I miss to set up some permissions?

Thank you,

Jaunney

PS: If I type vcgencmd display_power -1 7, the result is display_power=-1 don't know why...

grenagit commented 2 years ago

Hi @Jaunney,

What is the result of lsb_release -r? And uname -a? And cat /proc/device-tree/model?

Jaunney commented 2 years ago

Hi,

lsb_release -r > 11 uname -a > Linux raspberrypi 5.15.67-v8+ #1585 SMP PREEMPT Tue Sep 13 17:40:13 BST 2022 aarch64 GNU/Linux

grenagit commented 2 years ago

And what Raspberry Pi model ?

Jaunney commented 2 years ago

4 B

grenagit commented 2 years ago

4 B

Unfortunately, I do not have a Pi 4B but we will try to understand the problem with your help!

PS: If I type vcgencmd display_power -1 7, the result is display_power=-1 don't know why...

First possibility, the Pi 4 has 2 HDMI output. What is the result of?

Jaunney commented 2 years ago

Yes, it has two HDMI outputs, I tried both with same results.

the results are:

vcgencmd display_power -1 > display_power=1 vcgencmd display_power -1 2 > display_power=-1 vcgencmd display_power -1 7 > display_power=-1

Furthermore I found some articles, that the issue is related to the newest version of debian "bullseye", with "buster" it should work??

MaLeSwi commented 2 years ago

Hello all,

the problem is definitely related to vcgencmd on Raspberry Pi OS Bullseye. Please have a look at #https://github.com/raspberrypi/userland/issues/727

Proposed solution: Use of xrandr and/or xset

Have a good day!

grenagit commented 2 years ago

Proposed solution: Use of xrand and/or xset

Thanks @MaleSwi, I was just integrating xrand into the module, I also added xset. For my part, the problem seems fixed under Bullseye 🎉

For your part, can you install the testing version to confirm the resolution of this issue?

cd ~/MagicMirror/modules/MMM-PIR-Sensor-Lite
git pull
git checkout testing

Thanks for your feedback!

MaLeSwi commented 2 years ago

Hello @grenagit

Thank you for your prompt response and the test version.

I did a quick test on Debian 11 Bullseye.

  1. vcgencmd: Did not work as expected.
  2. xrandr: Worked in principle, with some side effects.
    • It rotated the display to landscape format after each screen activation. I configured portrait format (rotation 90° to the right) by default.
    • As soon as the screen is turned off, the image transfer via VNC is reduced to a tiny 320x200 pixel view.
  3. xset: Worked fine. Two comments:
    • Screen blanking must be enabled to make DPMS commands working.
    • Positive side effect: even with the screen off, the user interface can be viewed and operated via VNC.

For me, xset is the favourite solution.

Thanx again, @MaLeSwi

BlouZbee commented 2 years ago

@MaLeSwi

xrandr --output HDMI-1 --auto --rotate right should work for that situation!

grenagit commented 2 years ago

xrandr --output HDMI-1 --auto --rotate right should work for that situation!

Thanks @BlouZbee, I added a small additional parameter to support this type of configuration!

@MaLeSwi, Can you confirm that xrandr is now doing well is work?

cd ~/MagicMirror/modules/MMM-PIR-Sensor-Lite
git pull
Jaunney commented 2 years ago

Thanks @grenagit for your work! Now the deactivation is working! Unfortunately the PIR-sensor is not re-activating the display, although it's showing me motion detection while still on. Do you probably have any suggestions for this problem?

The commands xrandr --output HDMI-1 --off xrandr --output HDMI-1 --auto xrandr --output HDMI-1 --auto --rotate left

are all getting the result: Can't open display

grenagit commented 2 years ago

Unfortunately the PIR-sensor is not re-activating the display,

My bad, it's okay now!

Jaunney commented 2 years ago

Sorry, but git pull is getting me (Sorry about german system language):

Identität des Commit-Erstellers unbekannt

*** Bitte geben Sie an, wer Sie sind.

FĂĽhren Sie

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

aus, um das als Ihre standardmäßige Identität zu setzen.
Lassen Sie die Option "--global" weg, um die Identität nur
fĂĽr dieses Repository zu setzen.
fatal: Konnte die E-Mail-Adresse nicht automatisch erkennen ('pi@raspberrypi.(none)' erhalten)
grenagit commented 2 years ago

Did you change the module source code?

You can try git reset --hard...

Jaunney commented 2 years ago

No, I didn't change anything. But I just reinstalled the module and now activation and deactivation is working. Thanks for your help! Only the landscape issue is still there. The result of xrandr --output HDMI-1 --auto --rotate right is still: Can't open display

Some further testing: I had to use export DISPLAY=:0 then the xrandr command is working, but with HDMI-1 and the option rotate left But after reactivating the screen is again in landscape mode. Is it possible to edit your additional parameter?

Aaaaah, sorry, I just found it in your new readme. THX, everything is working now! Sorry, for stealing your time.

grenagit commented 2 years ago

THX, everything is working now!

Thank you for your final feedback! The new version has just been published :smile:

MaLeSwi commented 2 years ago

Please excuse my tardiness. I have checked all the new options. It works without any problems.

Thanks to all involved for fixing the problem so quickly!

TangoE3O commented 1 year ago

Hi All,

Passing along some info as I was also having problems with my ASUS VZ27EHE, a non-CEC monitor, staying off / my monitor coming back on, even after the module update (March 2023). The display would turn off, then a blue screen come on saying " HDMI No Signal " but then automatically turned back on with NO activity occurring (timer was at 0 but as soon as I moved, it was come back to the reset time). I used both xrandr and xset commands but nothing worked on my pi 4 running Bullseye.

After some digging and looking at this site https://github.com/raspberrypi/linux/issues/2517, I replaced the code in the node_helper.js line 81 (I know you’re not supposed to touch but this is what worked for me) and it works now. The only issue is on reboot, I have to run a command once to avoid the screen going to a gray state xsetroot -display :0 -solid Black.

case 'xset':
    exec("xset -display :0 s noblank", null);//default: xset dpms force off
    //Have to run 'xsetroot -display :0 -solid Black' on reboot to avoid gray screen
    exec("sleep 1", null);
    exec("xset -display :0 s off", null);
    exec("sleep 1", null);
    exec("xset -display :0 -dpms", null);
    exec("sleep 1", null);
    exec("xset -display :0 s 0 0", null);
    exec("sleep 1", null);
    exec("xset -display :0 dpms 0 0 0", null);
    exec("sleep 1", null);
    exec("xset dpms force off", null);

Don’t ask me how it works and I’ll give credit to E3V3A for posting that code. Hopefully this will help for those with a non-CEC compliant monitor and can fully turn off the monitor when not in use.