Create an item from an existing one

Hi, I’m installing 8 door and window sensors, the things and items properties are just the same except for the names, labels, semantics, mqtt topics,etc. I can replicate Things from the Code tab, by just copying the channel codes and pasting them, only modifying channel names and labels where applicable. My question is, can I do the same with items? Each sensor has 3 channels, I have to create and link 3 items for each sensor, I’d like to replicate them to the remaining things as I do with thing channels. Is it possible? I’m using the UI of openhab 3.

In OH 4, there is a code tab for Items. But note that this will not include Links which are managed separately from the Items.

In OH 3, there is no code tab for Items in OH 3.

The most efficient approach will be to use “add equipment to model” or “add points to model” to create all the Items linked to a given Thing in one go. This lets you set all the properties, situate the Items in the semantic model (remove the semantic tags if you don’t want to use the model), and create the Links between the Items and the Channels.

You can use the REST API to query for the “example” Item and then modify that JSON and post it to create a new Item. But again, this won’t include the Links to the Channels.

You use “add Items from text definition” to add a bunch of Items using the .items file syntax. But you have to know and understand the .items file syntax to use it.

Thank you for your fast reply. I should’ve used the first approach, shame on me… :blush:
I cant use the rest api because I’m doing it remotely and dont have access to the openhab server. The text definition is also an option, definitely. Will give it a try now. Thank you again and have a nice day!

If you can access MainUI you can access the REST API. MainUI doesn’t work without the REST API.

Go to Developer Tools → API Explorer.

“Add items from textual definition” did the job, thank you very much!