I have been trying to clean up some openHAB health issues, and one of them pointed out that no default persistence service was defined.
I had never touched those settings before, so I started looking into them and noticed that I currently have MapDB, InMemory and rrd4j installed.
Based on the persistence policies, the setup seems a bit redundant. Both MapDB and rrd4j have everyChange and restoreOnStartup enabled, while rrd4j additionally has everyMinute enabled.
Does it make sense to have both configured this way?
Is there a beginner-friendly guide that explains the differences between the persistence databases and what a good basic setup should look like?
Just to add a little to what @Hans_Lree said, you probably only want restoreOnStartup on MapDB only, not on both. That’s the only redundancy though.
You want MapDB for restoreOnStartup because it supports all OH Item types, it’s embedded so it’s guaranteed to be available when OH needs to restore the Item states, and because it only saves one value per Item it never grows. rrd4j only supports numerical Item types so you can’t use it with, for example, a String or Location Item which makes it less suitable for restoreOnStartup.
You want to store everyChange on both to ensure that both have all the state changes stored. You don’t want to miss any and often you want to know exactly when the Item changed state. rrd4j additionally requires everyMinute because of how it works internally. It needs a regular collection of data so the compression it performs over time works properly.
This reply I just made on another thread might be informative as well.
One more thing, the “default persistence” is the persisitence that OH will use if you don’t tell it otherwise. rrd4j is a good choice.
I have all items to be persisted in mapdb and restore on start up.
Then I have rddj4 group and that group is in the rddj4 persistence and I save to that on every change and 5 minutes etc so I can get graphs. It is NOT restore an start up.
Works well. I have had it like that for ages.
Example I have gTemp to graph temperature and gFronius to graph my solar.
I now have MapDB configured for all Items with everyChange and restoreOnStartup, rrd4j for all Items with everyChange and everyMinute, and InMemory for all Items with forecast.
Is my understanding correct that the assignment of Items to persistence services happens in the persistence configuration, where I currently selected all Items for each service?
I also have a question about cron strategies. MapDB has none, rrd4j has everyMinute, and InMemory has everyMinute, everyHour, and everyDay. What is the purpose of a cron strategy compared with everyChange and everyMinute in the configuration section?
Yes. Under MainUI → Settings → Persistence ->name of persistence you can set up which Items are persisted under which strategies. @ubeaut uses one approach where the persistence is configured to save all members of a Group and then controls which Items are persisted by adding or removing them from that Group. But you can see there are lots of ways to select and exclude Items from persistence.
rrd4j requires there to be a value saved every minute (unless otherwise configured). Without this rrd4j will not return meaningful results on a query.
But sometimes you may want a periodic strategy so your charts don’t end prematurely. The charts are only going to show a graph where the database returned a value. If the last time the Item changed was yesterday the graph may not show anything at all.
Sometimes you want an average of a value over time and want to avoid dealing with cases where there are no values to average because the Item didn’t change.
It all depends on what you want to do with the value being saved.