hjelev / rpi-mqtt-monitor

Raspberry Pi MQTT Monitor gathers system information and sends it to a MQTT server.
GNU General Public License v3.0
176 stars 42 forks source link

Feature request: option to switch a display #100

Open rpring01 opened 5 months ago

rpring01 commented 5 months ago

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

hjelev commented 5 months ago

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.

rpring01 commented 5 months ago

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.

hjelev commented 5 months ago

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.

rpring01 commented 5 months ago

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?

hjelev commented 4 months ago

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)

rpring01 commented 2 months ago

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.