Error in removing items in .items config file

Hello,

I came from OpenHAB 1.8.3 where all items had to be hardcoded in the .items config file. During runtime, I can always remove an item seamlessly without having to restart the service. I just have to save the file and OpenHAB does the rest. But in OpenHAB 2, whenever I remove an item in the .items config file, some “leftover” item gets stuck in the UI. These leftover items can be removed by restarting the service but I don’t want to do this. And no, using PaperUI or any other UI is out of the question because I am actually using my own application that fiddles with the OpenHAB’s config files.

Is it possible to seamlessly remove an item from the .items config file by just configuring something with OpenHAB 2? I’ve read that OpenHAB 2 now uses a database to store the items in and I’m wondering if this has any correlation with my problem.

(Top pic) This is the sample group containing some of my items. I will try to remove the Orange item.

(Right pic)This is the config file, the highlighted part is the configuration for the Orange item, which I will remove

(Bottom pic)As you can see, a “leftover” item took its place (I6N7_0002). This item no longer does anything. This does not happen at all with OpenHAB 1.8.3.

I think the answer is “yes, that’s right”
OH2 builds a cache of Items in JSONDB, and so behaves differently to OH1

To make changes on the fly you would need to understand and edit that DB.
The location is given here, as a first step

I’m not sure if REST API deals with this properly?

Hmmm - it’s not really a cache - it’s a persistence database. Just to be clear, it is only used to store data that is modified or managed through the user interface. If you use .items files, then in theory the data should not be stored in the database. If it is, then it’s a bug and of course this could be the case, and it could explain the issue here.

You can’t edit this database “on the fly”. This is not its purpose, and any edits will be ignored. The only time the database is read from disk is during system startup. So, you can use this set of files like the old text config files if you want, but you would need to stop the system, make the changes, and restart again.

I’ve already found a way and that is to use REST API, sorry for my shortsightedness. But I have another problem in using this. In adding a new item to the registry, I don’t know how to configure the bindings needed for that item. I also don’t know how to configure the groups, rules, and sitemaps. When I learned of REST API, I wanted to abandon the config files altogether and switch to REST API which seemed more neat to use. But as far as I’m seeing, REST API can only handle items. I also can’t find a documentation for REST API.

I’ve discovered that the items set in the configuration files cannot be managed by the REST API. Meaning that setting the items up in the config files and having REST API delete them, which solves my very first question, is in no way possible. I have to go all the way towards REST or stay with the config files.