When you have persistence configured you come to a point that you want to know how much data you have in your openHAB2 data base or you want to delete old item states like discussed for example here:
I created two python scripts which could be helpful also for others, so decided to make them public. You can use them for
Creation of a CSV file with an overview over your data in the database
Deleting of item data older than a configured number of days
I prefer value deletion individual by age per item as in those mentioned thread automatically with sql-procedure.
But what I’m still searching for is a tool, checking all items from persostence table items against actual active items from openhab2, so i can decide / mark items in sql to delete and drop the tables not needed anymore.
This script goes over all data base tables and link them with the actual items in openhab. If you filter for “-.-” in the sheet for example in column label. you see all tables in the db which don’t have an item in openHAB anymore.
I searched for a more automatic way. But I nearly got my solution. A rule increasing in items table how many cycles the item is inactive allready working.
I ll write a sql procedure now deleting items older x month next.
UPDATE: Script with Tutorial ready and checked. Automatically deleting old unused tables of actual inactive / earlier Items.