Review OH2.5.x config and remove dead items and code?

I have now been a happy openhab’er for a while now, and have a quite extensive config with multiple devices in my smarthome spanning zwave, zigbee and items in my config reacting on MQTT, HTTP, EXEC bindings etc.

However, I can see from my config, that I also have quite some items configured which are not really relevant anymore - items that I set up to play / test which are now just “there”.

Are any of you aware of a “review tool” with which I can get an overview across items, rules, sitemaps, things and “report” what elements are unused ? I.e. items not referred anywhere - or rules which are never triggered ?

That would make a cleanup effort much more available to me. Alternatively I could start over fresh (but I hope not) :wink:

OH3 with the remoteopenhab binding gives a good opportunity to migrate the used parts to the new version. That is likely your best path.

I understand this, but I would prefer to have a “cleaner house” to move over from, hence the reason for asking if there is some kind of tool/script which could clarify what “dead code/items” exist ?

I’m not even sure what such a tool would look like but the short answer is no. There is no such tool. And some of the information you are after is simply not available at all (e.g. rules which are never triggered). But you can do a whole lot using grep on the config files/JSONDB.

There is nothing you can do but manually go through your bindings to see which ones you are not using.

Then you can grep through your .items files or the links JSONDB file, or query for all the links through the JSONDB to find those Things that do not have any Items linked to them.

Repeat the process for all the Items to find those that are not linked to any currently configured Thing. But for Items you also need to grep through your Rules to see if it’s referenced. But it’s not necessarily that simple because, if you are writing rules well they are written generically which means your Item names may not even appear in the rules files but are still used by the rules. So you will need to still manually look through and understand your rules along side your Items to understand what Items are used by which rules. As for rules that are never triggered, you’d just have to monitor the logs (have a log statement in each rule) and after a suitable amount of time see which rules didn’t trigger in that time.

All things considered, it would be easier, less work, and more foolproof to transfer your config little by little. Note that transfer does not necessarily mean reimplement. Set up a new OH instance somewhere. Then move stuff over to it little by little. For example, move all your lighting over. But do it deliberately, reviewing each Thing, Item, and Rule individually.