Now that I have openHAB up and running, I will need a way to work with it.
There are two ways to work with openHAB. The PaperUI and configuration files.
What is PaperUI ?
Its a web based interface that allows you to do a lot of the things openhab provides in your web browser.
To use it, open a web browser and then use the IP address of the machine, openHAB runs on, and add “:8080” to the end of it. The last bit indicates the port, where openHAB is accessible through. I talk how to find the IP address in this post.
Form the tabs displayed, choose PaperUI.
When looking around, you’ll see ways to install Bindings, set up Things, create Items etc. The developers really have done a great job making configuring openHAB easy, and less daunting. Because, let’s be honest, if someone without programming background sees a black screen with a lot of code on it, they automatically assume the worst. PaperUI makes the job more visual and like using a simple app.
Why don’t I use PaperUI ?
Unfortunately, if you are planning to create more complex automated systems, you will get stuck with PaperUI. For more demanding users, which I, and most likely you are, the way to go is working with configuration files directly.
These files are text files. Therefore you could edit them with any text editor. Notepad, Wordpad…. Yeah right. Nobody is going to use them. But Notepad++, Atom and Sublime Text would be real alternatives.
It also would be a good thing to know how to use nano text editor, when you are logged in via ssh. You probably won’t use it to configure openHAB, but you never know when you might need it. Have a look here for a quick nano tutorial.
The best way is – Visual Studio Code
The best way, by far, in my opinion, is to use Visual Studio Code and the extension for openHAB with it.
Visual Studio Code is a free editor from Microsoft, no to be confused with Visual Studio. Although, if you know Visual Studio, you probably won’t confuse them.
Once you have VS Code downloaded, installed and opened, click on the extension tab on the left hand side of the window.In the search bar, type openHAB. And that will search for all the available extensions. Select openHAB, then on the window that opened, click install.
Once the extension has installed, open the configuration files by going to File>Open Folder. Now from Network, choose PINE64SO and you will see a folder called openhab. Highlight the folder and click Select Folder.
Now all the openHAB files, that we will need to work with, are opened on the left hand side of the window.
If you go through the folders, you see that each of them only has the README file in it. Each file points you to a web page, that holds the relevant documentation about that particular folder. I highly recommend you spend a bit of time and read through the documentation they have provided. It might seem a little overwhelming at first, but it does a great job explaining how openhab is built. And even if you dont understand everything, this way you know where to find more information if you need to.
Now you can start writing code, to automate your home.
Error while connecting to openHAB REST API !
You may or may not come across an error though when you start editing. If you do, that is because VS Code is not yet properly talking with openHAB.
To fix that, click on Set openHAB Host in the error tab.
That will take you to the settings tab. Select User settings, the go down to Extensions and find openHAB Configuration. Under Host, click “Edit in settings.json”
Now paste in this :
Where openhab host address is the IP of your machine that runs it. Now on the error tab, click disable REST API. If you start editing again, you are going to see suggestions from VS Code. Choose the one you want and hit Tab.
This is an awesome addition when writing code. It helps you save time and most of all, helps you avoid typing errors.
I wish I had it all set up when I first started with it. I spent a good hour trying to figure out why my rule isn’t working. Everything seemed fine. But it turned out, that I had forgotten to write “end” at the end of a rule structure I was working on. Needless to say, I was swearing a lot that day.
And that is it for this post. Now you are ready to configure openHAB.
You can also find a video about this post on my YouTube channel – smarESThouse . I will be adding new videos weekly. So go a have a look there as well.
In the next post I will talk about the basic concepts of openHAB and the way I made sense of it.