[SOLVED] Rule from for executeCommandLine - Touchscreen backlight

(Jozef Szabo) #1

Hi,
I wish to awake my touchpanel via Alexa voice command from backlite off state to on.

I think is a nice idea to control backlight if i need to read something from display for a while and after timetout the screen puts blacklight off.

please how should be correct inserted for executeCommandLine statement:

**shell cmd line:**
sudo sh -c 'echo "0" > /sys/class/backlight/rpi_backlight/bl_power'

**Rule line not working for me:**
executeCommandLine("sudo@@sh@@-c@@'echo@@0@@>@@/sys/class/backlight/rpi_backlight/bl_power")

Thanks for help.

0 Likes

(CM6.5 H102) #2

Do you have the Exec binding installed and does openhab have the needed permissions to run the sudo command?

Also see this topic.

0 Likes

(Jozef Szabo) #3

Thanks, Exec Binding was of course installed.
Thanks, Exec Binding was of course installed.
Solved with python script and openhab rule.
Trick was - leave sreen forever unblanked!
Add lines
@xset s noblank
@xset s off
@xset -dpms
to /etc/xdg/lxsession/LXDE-pi/autostart

Python script display.py:

#!/usr/bin/python
openFile = open("/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/bl_power", "r+")
status = int(openFile.read(1))
if status == 0:
    bl_set = 1
else:
    bl_set = 0
bl_update = str(bl_set)
openFile.seek(1)
openFile.write(bl_update)
openFile.close

Rule:
executeCommandLine(“python@@/etc/openhab2/scripts/touchpanel/display.py”,1000)

I’m using https://github.com/timothyhollabaugh/pi-touchscreen-timeout for switch off screen backlight after timeout 30 sec.

0 Likes