I’m running OH 4.1 on Linux, as JDBC database, I use MariaDB.
For some reason, I get double entries in the database when using ‘EveryUpdate’ as a strategy for that specific Item. The Item is not in a Group policy.
the Item with the double entry is the one starting with Netatmo_regen, jdbc.persist looks like this:
First of all it’s important to realize that strategies are additive. So all your items will have everyChange and restoreOnStartup. In addition to those, Netamo_regen_RainDelt will have everyUpdate.
Since a change is an update the value gets saved once for the change and again for the update.
hi @rlkoshak thanks, I tried already to delete the default strategy, worked but no other item was updated. The double entries in the database are all after a change in valure, so the strategy does what I told it to do. But how do I tell the default is on everyChange, and the exepctions should update on everyUpdate.
Well, of course not. When you remove the default you have to explicitly list each Item you want to save to persistence.
You don’t because there is no concept of “exceptions”. Like I said above, the strategies are additive. * applies to all Items whether they are listed elsewhere in the persistence config or not.
So your choices are:
Make * the minimum strategy possible (restoreOnStartup) and then you need to list each of your Items separately with the strategy desired. You can use Design Pattern: Group Based Persistence to make that a little less work. Though if your minimum strategy is only restoreOnStartup you should probably just exclude the * line entirely and add restoreOnStartup to the other lines because restoreOnStartup doesn’t make sense if you don’t also have a strategy to save that Item too.
Make default strategy be everyUpdate which will capture the changes too without the double entries. You’ll have to live with the fact that some of your Items will save more data than necessary (not every Item will receive updates when there is no change so it probably won’t be a lot of entries).
Thanks again, Rich.
I picked option 2, since managing a few hundred Items sems to be complex. And the additional storage isn’t that big a deal. Works like a charme, and I learned a thing or two on persistance