Binding creation - Some questions before I start


First of all I am completely new to this kind of development.

I want to create an Midea air conditioner binding.

What I already have is an python script, which is able to auto discover if there is any midea air conditioner in the local network.

Then I have a pearl script which can handle all the different commands perfectly reliable via LAN (without the Midea cloud), like setting temp, mode, swing etc.

Since openhab bindings are in JAVA language how do I make use of the working scripts I already have ? Do they need to be converted into Java language or how exactly would that work ?

It depends a bit on what you want to do with your binding. If you want it included in the openHAB distribution than yes you need to rewrite the binding in Java.

Yes I would like to get it included in the openHAB distribution, so everyone in this community can benefit from it.

Will take a look at how to convert the scripts into java language.

If you already have working code in Python and Perl, and you have at least some basic knowledge of Java, it probably shouldn’t be too hard to create a binding.

I’d recommend reading through the first three sections in the developer docs (Overview, Coding Guidelines, and Bindings) first.

There is a script that will create a skeleton binding for you to use as a starting point.

Then take a look at a few existing bindings that do something similar to what yours will need to do. For example, if you are accessing a REST API with JSON payloads over HTTP. look for another binding that accesses a REST API using JSON payloads over HTTP. This will save you a lot of time, since everything you need to know is probably not in the docs.

There is an XML file that describes the things and channels that your binding will provide. You may want to think that through before you jump in to the actual binding code.

Finally, I’d recommend using Eclipse as a dev environment unless you really feel strongly that you need a different one, since that is more or less the standard dev environment for openHAB.

Happy coding!

1 Like

Thank you for all the great tips.

I will definetly try it myself and try to get it working.

But in case I am not able to do it.

Can I somewhere post a thread/request with a reward if someone would translate the perl script to java and create the binding with it ?

People here usually use bountysource for that.