I am making a data dashboard using Node-Red. My end goal is to use data from a motion detector to turn on and off the raspberry pi 7" display by sending: sudo xset dpms force off
to the pi. I've tried exec node, but I can't find an example that closely matches my use case. I'm having no luck passing the command through the exec node so far.
I'd appreciate any help, thanks!
Correct command using script thanks to @hardillb
I placed my script in /home/pi
Just a thought, xset requires the DISPLAY env variable to be set and point to the active display.
If you are running Node-RED as a service then this variable is not going to be set.
Best bet is to create a short shell script to set the variable and run the command:
#!/bin/sh
export DISPLAY=:0.0
sudo xset dpms force off
and then point the exec node at the shell script.