Hi, can anyone please help to understand how to not persist the items data. Let me explain:
I jsut freshly deploy docker container with OpenHAB - all is running smooth and configuration was easy (I havent setup any persistence settings nor isntalled any persistence add-on). But still I’m able to get items history data eventhough I dont want to - Im interested in current state (item value only) - for some items Im nto interested in history.
Can anyone please help to understand how to achieve this?
If you don’t want historical data, install MapDB persistence and then set up a mapdb.persist file with your strategy. MapDB only persists one value. You can then uninstall the default RRD4j persistence service if you don’t want it, or leave it running and just not use it.
Here’s the basic everyChange strategy that restores MapDB values on startup.
If you just want to remove some items from your RRD4j persistence, then you’ll need to define a strategy in an rrd4j.persist file that only persists the items you choose. I can’t help you with that, but there’s lots of information in the Persistence documentation.
Just to elaborate a little bit on @rpwong’s answer.
each persistence add-on comes with a default strategy which is almost always save every Item on everyChange with restoreStartup
to override the default strategy, you have to create a properly formatted .persist file under /etc/openhab/persistence
the .persist file strategies are an allow list. There is no way to exclude specific Items from being persisted. Instead you need to explicitly define which Items are persisted and how. When you use * for the list of Items, that will apply to every Item. There is no way to say “every Item but this one”.
Thank you both - i would prefer to not have any add-on in this regards. Can i define the strategy of not storing the data with the default rrd4j ?
I’ve checked the documentation before sending this post but in the documentaion I was able to find how to store the data and what should be the granularity but I was not able to find how NOT to store the data
Not sure what you mean…
If you do not want to persist at all: remove RRD4j db from openhab (menu „other addons“)
If you want to exclude a few items from persisting you have to list those items which you want to persist as described above.
even though you may not be interested in historic states. What’s your issue with it?
in case openHAB restarts, the default persistence (rrd4j with a vanilla installation) restores your items to the last known states.
Is there a relevant use case to not have items persisted at all?
apart from that → Rich already anwered your question here. just edit the rrd4.persist file and don’t use *, but only those items/groups you want to persist. or leave it empty to not use that persistence at all.
Hi, I missed the fact that rrd4j is installed in Vanilla instalation → now I understand the behavior. Just to be clear about my use case. I’m planning to store lets say 10 number elements with 60s frequency so after one month there will be roughly 500k records and my concern was about the performance and disk space. Since I dont need the historical data I need to do the decisions on current state of the elemnts. I was wondering how to achieve this.
Also an option to delete the old data will be nice
That’s not how rrd4j works. rrd4j remains a constant size. It does this by requiring a record on a fixed period. Then, as the data ages ten stored values are replaced with the average of those values. So for the first hour you may have one value per minute but month old data may only have one record per hour and data a year ago may only have one value per day.
The only way that rrd4j persistence storage needs change is by adding Items. Each Item get a fixed amount of disk space though.
Perhaps that’s a misunderstanding from your side. As Rich explained, rrd4j already got its designated disk space. Performance of that is of no issue, I’ve got >1300 items with but rrd4j (every item) plus MySQL persistence on top. Running just on a raspberry Pi 4 (4GB). Should be easy on your docker host.
But - and that’s the important part: you only ever use historic data, if you’re either building charts (ootb in OH3) or you explicitly tell OH to use historic states in e.g. rules. Otherwise of course openhab always works with current values - as it’s stateless by design. Of course, persistence layer is there to provide easy access to past information or startup restoration of states after an application restart or reboot, update…
So, the advice is strongly: use persistence unless you already have experience with openHAB and know exactly, why and what you’re doing.