Searching a simple example for Binding

Hello guys,

I am a student and now have to create my own binding as a student research project. The binding should be able to communicate with another Rasberry Pi, so that this can then switch LED or similar. So far I have looked at some documentation on how to create a binding, but I still can’t make much progress.
As you know, you learn best by reproducing old projects and see how they are built. I have looked at the MQTT and the Network Binding so far. However, these are very complicated in my eyes and confuse me even more.
My question now is: do you know bindings that are very simple, where you can understand and learn a lot?

About my progress: I have already created a binding with Maven via Visual Studio Code and I can add it in Openhab. Then I looked at the XML files, with which I can create Things and Channel. Now I wonder, for example, how I can get to or use the config parameters of a registered IP in the Java file (ThingHandler). With a simple example, I would like to teach myself all this.

Thanks already for the help

The NTP Binding is very simple. It allows you to create and configure a Thing for a time server using a hostname. Time is also something everybody has good use for. :slight_smile: You can find the code in bundles/org.openhab.binding.ntp.


Youre right. The NTP Binding helps me a lot.
I am at the point where I need to customize the “handleCommand” method.
Now I read in the development guide that there is the RefreshType command and the SwitchType Command. My question is now if there is a list or something like that, where all commands are listed and what exactly is in this object? For example I can find out with the SwitchType by “convert((OnOffType) command)” whether the switch was switched on or off. How is it with other commands to query contents?

1 Like

Typically you handle commands for a channel by checking the channel UID and also what type of command is received using instanceof as documented in Handling Commands. Once you know the type (using instanceof) you can cast the command to the Command subclass.

The types of commands that can be received by a channel depend on what kind of <item-type> the channel has in its Channel Type definition.

The Items documentation has a table with the Command Types for each Item Type. See the classes implementing the Command interface in the JavaDocs for the exact Java class names.