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

xrandr Not Finding HDMI-1 Without Display Being Set #8

Open john3300 opened 1 year ago

john3300 commented 1 year ago

I was just testing your module and was having trouble with thexrandr commands not having any effect. I added some additional logging to the exec() command to capture stderr and found this for both turning the display on and off:

[ERROR] stderr: warning: output HDMI-1 not found; ignoring

After a bit of playing around I was able to get it to work by changing the exec() lines in node_helper.js from: exec("xrandr --output " ... to: exec("DISPLAY=:0 xrandr --output " ...

With this change in place, both on and off are working. I don't know why my system needs that to work, but I thought I would share it with you in case this is something you haven't seen before. Maybe something to add to your implementation? I can submit a PR with the change if you would like.

Here's my system information if you're interested:

pi@magicmirror:~/MagicMirror $ lsb_release -r
Release:    11
pi@magicmirror:~/MagicMirror $ uname -a
Linux magicmirror 6.1.21-v7+ #1642 SMP Mon Apr  3 17:20:52 BST 2023 armv7l GNU/Linux
pi@magicmirror:~/MagicMirror $ cat /proc/cpuinfo | grep Model
Model       : Raspberry Pi 3 Model B Plus Rev 1.3

And here's my config.js entry:

{
    module: "MMM-PIR-Sensor-Lite",
    position: "bottom_left",
    config: {
        sensorPin: 4,
        rotation: "right",
        deactivateDelay: 1 * 60 * 1000,
    }
}
grenagit commented 1 year ago

Strange, everything works fine for me (same config)... What is the result of xrandr --listmonitors?

john3300 commented 1 year ago
pi@magicmirror:~ $ xrandr --listmonitors
Can't open display 
pi@magicmirror:~ $ DISPLAY=:0 xrandr --listmonitors
Monitors: 0
umbynos commented 11 months ago

Same problem here with this setup:

umberto@magicmirror:~ $ lsb_release -r
No LSB modules are available.
Release:    12
umberto@magicmirror:~ $ uname -a
Linux magicmirror 6.1.0-rpi4-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.54-1+rpt2 (2023-10-05) aarch64 GNU/Linux
umberto@magicmirror:~ $ cat /proc/cpuinfo | grep Model
Model       : Raspberry Pi 3 Model B Rev 1.2

and this config:

               {
                        module: "MMM-PIR-Sensor-Lite",
                        position: "top_right",
                        config: {
                                sensorPin: 4, // GPIO pin
                                commandType: "xrandr",
                                hdmiPort: "HDMI-1",
                                rotation: "left",
                                deactivateDelay: 10 * 60 * 1000, //10 mins
                        }
                },
gonzonia commented 11 months ago

I found that I needed to set the display when I was connected over SSH. If I ran the commands directly from the machine it worked. I don't know if that helps you, but it might point you in the right direction for finding a solution.

ehrenberg commented 10 months ago

I found that I needed to set the display when I was connected over SSH. If I ran the commands directly from the machine it worked. I don't know if that helps you, but it might point you in the right direction for finding a solution.

And how to set the Display? Can you give more Informations please?