# OpenHab gpio button

Date: 2017-09-13

I started with [openhab](http://www.openhab.org/) and figured out that getting a button pressed to react is considered one of the most challenging tasks

The setup is simple, raspberry pi 3 with two jumpers from pin four and GND. To simulate button press, I connect them.

<!--more-->

1. Get your [openhabian](http://docs.openhab.org/installation/openhabian.html) and install it on the pi &#8211; 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 two 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

That's a basic example, but it seems that a lot of people find it hard to figure out what's going in openhab,

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