New to binding development

I am very new to the openHab framework and I intend using it for my final project. I have being able to setup the runtime on a raspberry pi. It is now left with the binding development. I am going to use an arduino yun to build smart power socket and I intend to control it using a mobile app. I have set-up the eclipse smarthome development IDE, I tried setting up that of openHab but my internet connection is bad. But since the ESH and OH2 have the same architecture if I am right.

I intend to use COAP or MQTT (have read a little about them). I will be happy if Someone can help me out with the binding development and someone I can message about from this platform.

First make sure the existing bindings are not suitable for your needs. There is already an MQTT binding, TCP binding, Serial binding, and HTTP binding that others have used to communicate with this sort of system.

There are already sooooo many bindings, over 120 “official” ones at last count. I hate to see even more created, particularly in cases where you can achieve the same thing with existing ones.

Since you are already thinking of using MQTT, why not follow the common design pattern of having your Yun talk to a bridge wirelessly (or implement MQTT on the Yun directly) which talks to an MQTT broker. Then using the MQTT Binding openHAB sends and receives messages through the broker. I and many others have successfully used this approach and no new bindings are required.

Save the development of a new binding for only those cases where you need to interact with a custom API, have authentication requirements that the existing bindings can’t handle, or you need to implement a specific protocol.

The whole idea is I need to develop my own binding. What do you suggest

Well, if it is just for yourself or a school project then go for it. It could be a good learning exercise.

But if it is a binding that you want to contribute to the community you need to find something that doesn’t already exist and has an API around it. Search this forum for people requesting information about whether a binding exists for X or Y for some ideas.

Exactly, it is because of a school project. They wont see alot of work done if I use existing ones. So my next question Im I suppose to use openHab 2 or ESH2, currently I have ESH2 IDE setup, my internet connection is not quite fast so I havent being able to set-up the openhab IDE. What protocols do you suggest I use for my purpose if I am to develop my own binding from scratch based on mhy system requirements.

It depends on how your Yun talks. If it is on an IP network I would probably put a webserver on the Yun with an API and then have my binding communicate with that. If you really want to create some value added, include some sort of mutual authentication between the binding and your Yun. This would both justify the creation of the new binding and address a growing problem in IoT, lack of security.

So if I am to go by the mqtt binding, how do I modify it to meet by needs.

That is the thing. If you use the MQTT, there is nothing to change. It does everything you need out of the box. All you do is config the binding to your items.

If you want to duplicate what it does in your own binding you can just look into the paho library and figure out how to use it in your code. In Python it only takes about 10 lines of code to set up and use, its really easy.

I intend to use java not python. Duplicate ?? I am new so please how do I config the bindings to my items.

is there an mqtt binding of the OH2 structure.

How do I use the openHab designer? Is it the one used for the sitemap design.

Don’t get me wrong, but it seem you have not read any of the avaylable documentation.
Documentation for openHAB2 can be found at:

How to start binding development at:
And as an example how to bind your items to a binding, have a look at documentation for the MAX! Binding at:

To edit item or sitemap configurations, you can use the designer or an editor like notepad++ under M$ OS.

I have read the first two. I am saying that I am new and some of the things I don’t really understand them. I intend to use MQTT and my colleague rlkoshak is saying there is a binding for that exist already.

If I intend to develop under org.eclipse.smarthome because that is the IDE I have setup now. How do I proceed to fit the MQTT binding to my use. Handling my items with the various channels.

As at now I have the openHab runtime setup on my raspberry pi and the demo-house is working.

Also the sitemap if I am to go by the org.eclipse.smarthome, can I still use the openHab designer( Is it what is used to design the sitemap).

I was just providing the Python example as how easy paho and MQTT is to work with in general. It should be a similarly small number of lines of code to connect to, publish, and subscribe to an MQTT broker in Java.

I have no experience in OH2 so I don’t know if there is anything different but in OH1 everything is documented on the wiki.. I believe that MQTT binding has been ported to OH2 so it should work and there is a compatibility layer so OH1 Items and Rules files will work with OH2 unchanged so it will work if you follow OH1’s format.

openHAB Designer is for editing ALL openHAB configs: sitemap, items, rules, scripts, transforms, persistence. I don’t know the state or maturity of Designer for OH2 so I can’t say how comprehensive it is at this time. I know a lot if changing regarding rules and the UI and I don’t know if the sitemap has kept up.

I think it would be a good idea to spend some time with the wiki and learning how OH1 works just as a user. Then I think the documentation for OH2 and how to develop a binding will start to make a lot more sense. The vast majority of openHAB users create massively complex configurations, including your exact scenario (remote Arduino with a relay that communicates via MQTT) without ever developing a binding.


I agree to reuse existing bindings if possible. I have a question pertaining to this. How does one go about seeing if a binding may work with something it wasn’t intended for? I ask, because I am wanting to write a binding for Vixenlights API.i am also having issues getting the openHAB runtime to run in the ide, have a thread open for that with no response

I don’t really do OH development so my advice is only worth so much. What I would do is try to see if the binding can be made to work through configs. If not I’d look to see what it would take to modify the binding to support it. If that is too hard or outside what feels appropriate for that binding, then I’d copy the relevant parts of the other binding (with proper attribution of course) and create a new binding.

I’m sorry you are having problems getting the dev environment up and running. I saw your thread but I’ve never attempted it myself so can’t help. As hard as it is to get started with using OH, it is twice as hard to get started with development. This problem was addressed a little bit during the recent Home Automation day in Germany (I haven’t watched that video yet but it was mentioned in the introduction).