I am using the Official RPi Touch Screen V1.1 and wish to be able to turn the backlight off with a button.
The command to turn the backlight OFF is:
echo 1 > /sys/class/backlight/rpi_backlight/bl_power
The command to turn the backlight ON is:
echo 0 > /sys/class/backlight/rpi_backlight/bl_power
Running this in an exec node gives:
Can some one advice if it's possible and how I run this as sudo cannot be used.
You can use visudo to tell the system that the node-red user is allowed to use sudo with that command without having to enter a password. Then it will run ok in an exec node. I don't remember the exact syntax you need in the visudo file but no doubt your favourite search engine will find it.
First check the command in a terminal with sudo, does it ask for a password? If not then it will run in an exec node.
Thank you for replying. I did delete this message as I created a bash file in /home/pi/display/rpi-lcd.sh , I will try your method.
This works in an exec node.
sudo /home/pi/display/rpi-lcd.sh off