I successfully use the Exec Binding 2.x to restart and shutdown my Pi so I’m reasonalby familiar with the setup.
That said I’m really struggling to get my head around why I cannot send another command. I’ve read How to solve Exec binding problems but to be honest it’s still a bit above my head.
The command that works in terminal is sudo bash -c "echo 50 > /sys/class/backlight/rpi_backlight/brightness"
My /etc/sudoers.d/common_users file contains the following:
openhab ALL = NOPASSWD: /sbin/reboot, /sbin/shutdown, /bin/bash, /sys/class/backlight/rpi_backlight/brightness
I created a thing in the PaperUI that contains the following (along with about 100 other tests ) without success:
After much deliberating here How to solve Exec binding problems I found the issue was due to the binding functioning oddly. The solution was to create a shell script that sat on my pi which was then called in the binding.
My /etc/sudoers.d/common_users file contains the following:
openhab ALL = NOPASSWD: /sbin/reboot, /sbin/shutdown, /bin/bash
I created the shell script like this:
# Create file
sudo touch brightness50.sh
# Make executable
sudo chmod u+x brightness50.sh
# Open
sudo vi /home/pi/brightness50.sh
# Paste
sudo bash -c "echo 50 > /sys/class/backlight/rpi_backlight/brightness"
# Convert
sudo vim +'set ff=unix | x' /home/pi/brightness50.sh
# Run
sudo sh /home/pi/brightness50.sh
I then simply added this to the run in the paperUI