Creating ITEM through REST-API - Openhab 2


I have different .items files in openhab and have several sitemaps as well. Basically for each room, we have a .items file and a .sitemap file.

Now, I wanted to insert a item for a room in one of the .items file through REST API. I tried using REST API to create a test item. The query works fine, but it does not create an ITEM in any of those files. I just see the item in Paper UI > Inbox > items.

How to use REST API to create an item in a specific .items file in Openhab 2?


Creating items through REST API is the same as creating items through PaperUI: those go into your JsonDB, not into any flat items file.

But how do we practically structure items and use it if it goes to jsonDB?
Should we write a local code to pull data from that dB and push it to items file? I just want all items to be structurally maintained.

A lot of users use this approach:

If using 2.x bindings, let your things autodetect. This does not work for 1.x bindings, you will need a *.cfg file.
Then create your items manually via text file and link the channels of your things to those items. Examples can be found in every bindings docs section.
Note that you can mix PaperUI configuration and flat text file configuration.
Summary: Things through PaperUI, items and channel links of your things via *.items files.
If you want to use BasicUI or ClassicUI, you also need to create a *.sitemaps file.
You may also take a look at homebuilder.

Thanks very much. Homebuilder looks interesting. May be I could modify homebuilder.