Modbus-rtu Opehabian

Hi, I’d like to rebuild my entire system from Openhab 1.8 to Openhab 5. I’m wondering how to manage the Modbus.
In version 1.8, there was an “openhab.cfg” file with all the programming.
For example:

modbus:serial.I21.connection=/dev/ttyUSB0:19200:8:none:1:rtu
modbus:serial.I21.id=1
modbus:serial.I21.start=21
modbus:serial.I21.length=1
modbus:serial.I21.type=holding
modbus:serial.I21.valuetype=bit

#TEMPERATURA INTERNA LAVANDERIA ID100 = DFTA = ( 100 ) // LAVANDERIA
modbus:serial.I100.connection=/dev/ttyUSB0:19200:8:none:1:rtu
modbus:serial.I100.id=1
modbus:serial.I100.start=100
modbus:serial.I100.length=1
modbus:serial.I100.type=holding

Can anyone explain to me how and where to enter all the data in the new Openhab 5?

I generated the things, now I have to continue.
Hi, thanks everyone.

Can anyone explain to me how and where to enter all the data in the new Openhab 5?

Hey,

here’s how I configured Modbus with OH5.

You first need to install the Modbus Binding.

Then as you use something connected via USB you most likely need to use a Modbus Serial Slave Thing and configure it with your values.

Additionally you need a Regular Poll Thing which uses the Serial Slave Thing as bridge. In the Poll Thing you can configure which register(s) to read.

The third thing you then need is a Modbus Data Thing. The Data Thing has the Poll Thing as bridge and uses one of the polled registers.

You could e.g. read four registers that have consecutive numbers with one Poll Thing. Then you create four Data Things where each one uses one of the polled registers.

In the Data Thing you can then create a “Value as Number” channel and link it to an item.

It’s a little bit confusing with all these Things, but in the end it’s quite straight forward.

To get it done quickly, ask a LLM of your choice. They all are really capable with openhab things/items… See Kermi Modbus Binding - #5 by daabm

All done with AI, no line I typed on my own in that…

Hi, sorry, I’m a beginner, what is an LLM?
How did you do it with AI?
So could my files from the old version be useful?

LLM is large language model - gemini, openai, anthropic, whatever you pick. don’t know if they understand your aged cfg files, but give it a try.

I really don’t know where or how to start

OH 2 completely changed the architecture for how OH works, adding a layer of bastraction between devices and Items called “Things” . This was done to enable the possibility of automatic discovery and integration of devices which was simply impossible the way OH 1.x was built.

In OH 3, the support for OH 1.x style add-ons were completely removed. Things are the only way going forward.

Unforunately, Modbus is one of the technologies that do not support automatic discovery. Consequently you will need to configyure everything yourself manually. But all the information you need should already be there in the OH 1.x Item’s configs.

It would probably a good idea for you to review Migration from openHAB 1.x to openHAB 2 | openHAB. Then go through at least the Things and Semantic Model parts of Getting Started - Introduction | openHAB. And, as the latter link tells you, also review the Concepts section of the docs.

OH has a ton of new concepts and capabilities.

To elaborate a bit on @engine’s answer, the stuff you put into openhab.conf will be used to create the Modbus Serial Slave Thing. This is what we call a “Bridge”. Once this is created and ONLINE you can proceed. You’ll create the Thing from MainUI → Settings → Things → +, or review the Modbus binding’s docs for how to create it in a file. (If you want to do files, I recommend creating it in the UI first, then you can export the file definition as either a .things file or as YAML).

The Bridge just establishes the connection with the USB device. Next you need to set up the Thing which gets the data. In OH, the expected approach is each Device gets it’s own Thing. You can put everything in one Thing but other parts of OH will work better if you stick to the one-device-to-one-Thing. Again, go to MainUI → Settings → Things → + to create the Modbus Poll Thing. Once create you’ll open the Thing and click on the Channels tab. You will create one Channel for each of the Items you have in your OH 1.x instance using the information in the modbus config of that Item.

To be sure to review the modbus docs for additional parameters and such.

Items are connected to Things using Links.

Once the Poll Thing(s) are created, you can choose “Add Equipment to Model” which will create all the Items with meaningful defaults, link them to the Channels, and situate the device inside your semantic model.

Again, if you really want file based configs you can then export these Items to either .items or YAML format.

Once you have the Items situated in the semantic model, they will appear in the Locations, Equipment, and Properties tabs of the Overview page in MainUI.

Sitemaps are also an option and while they have lots of new capabilities they are largely similar in structure to what you are used to in OH 1.x.