OpenHab gpio button

I started with openhab and figured out that getting a button pressed to react is considered one of the toughest tasks

The setup is simple, raspberry pi 3 with two jumpers from pin 4 and GND, to simulate button press I just connect them together

1. Get your openhabian and install it on the pi – this step took me around 3 hours

2. Go to http://[openhabian_ip]:8080/paperui/

3. Install the GPIO addon

4. Connect the device with ssh and add 2 files:

vim /etc/openhab2/items/btn.items

Contact NormallyOpenPushButton "Normally Open Push Button [%s]" { gpio="pin:4 debounce:10" }

vim /etc/openhab2/things/btn.things

contact:gpio:NormallyOpenPushButton

vim /etc/openhab2/sitemaps/test.sitemap

sitemap default label="My first sitemap"
{ 
Text item=NormallyOpenPushButton
}

 

5. Go to http://[openhabian_ip] :8080/basicui/

and choose the test sitemap

you should see one line that indicates if the button is close or open, touch the two wires and refresh and you’ll see it change state

 

This is extremely basic example, but seems that lot of people find it hard to figure out whats going in openhab,

more examples in the future when I’ll learn some more about openhabian