Getting started openhab + [Raspberry GPIO shell script read value]

Hi all here.

I am a totally newbiee, at openhab. So i am struggling getting started with it!

I have made a simple 4 relay gpio relay switch, which can be triggered by sending a command e.g.

Switch Light_FF_Corridor “Corridor” (FF_Corridor, Lights) { exec=“ON:/home/pi/scripts/switch/gpio28.sh 1, OFF:/home/pi/scripts/switch/gpio28.sh 0” }

I can do the same with GPIO29,30 and 31.

I found the example somewhere on the net, and eventhrough i can see, why it is working, i cant seem to find any documentation of howto move on from here?

I need an option for reading a variable e.g 1 or 0 or ON or OFF, from a file, so i can read the state of my gpio’s see here (Example)

#!/bin/sh

status=$(/usr/local/bin/gpio read 17)

if [ $status = 1 ]; then
echo “on”
exit

fi
echo “off”
exit

But how do i use it in openhab ?

Anyway, i would like some links for good tutorials, and maybee some good explanations of howto move on and learn the openhab…

Best Rgds; Jesper.

Have you looked at the GPIO binding?

That way you don’t need to create shell scripts for every pin. But you will have to run openHAB as root.

If you want to keep the scripts, see the Exec binding page which describes how to set up an Item that gets its state from the script (as opposed to executing the script when its state changes).

Thanks…

I will look into that!

Rgds; Jesper.