hjelev/rpi-mqtt-monitor

Feature request: option to switch a display

Opened this issue · 7 comments

Would it be possible to have a switch similar to the power off but only turn off/on the display. I am currently using the shell command 'xset -display :0 dpms force off' or 'xset -display :0 dpms force on'.
The mqtt option would avoid the ssh authentication issue.
I am trying to automate the touchscreen connected to the pi.
Thank you

Hi,
Yes I'll add this, it also works on ubuntu out of the box.
I am doing the same but with another script and use "ddcutil --display 1 setvcp 60 17" but this needs additional software + guessing the numbers after setvcp.
Do you happen to know a command that will output the status of the monitor(s) - I am using 2 monitors and your command works for both.

I am not sure of the command to check monitor status, my display is connected to the dsi port not hdmi. Although if you put -q at the end of the command you can see monitor status at the end of the list.

I have introduced the first iteration of your feature request.
If you reinstall the script it should work, else if you update you need to manually update os_user="your usedrname" this is needed as the service needs to run as root in order to shutdown/restart and to control displays it needs the user.
I plan to improve this to a switch with status, but lets see how this works.

I have reinstalled the script but don't see the option in HA to switch off the display, how do I use or test the function?

in the config.py there is a variable that is set to false by default
display_control = False
You need to change this manually to True
I'll update the installation script to ask for this or auto detect if there are monitors attached (if possible)

the display switch is working well thank you. is it possible to have a sensor show the status of the display to use in an automation? for the automation to work correctly I need to know if the display is on.

I'll look into this - should be possible