Hi Folks,
The docs refer to default persistence here: Persistence | openHAB
I’ve been using the default persistence for some time now and it works perfectly. However, I now would like to add MapDB as a second persistence config for a specific item. This is where the docs and the config gets confusing.
If you follow the UI > Settings > Add On Settings > RRDJ4 Persistence > Persistence Configuration and press save - this seems to override the default persistence settings. It seems to do this by creating a new file
/userdata/jsondb/org.openhab.core.persistence.PersistenceServiceConfiguration.json
configurations: []
cronStrategies:
- name: everyMinute
cronExpression: 0 * * ? * *
- name: everyHour
cronExpression: 0 0 * * * ?
- name: everyDay
cronExpression: 0 0 0 * * ?
defaultStrategies:
- everyChange
thresholdFilters: []
timeFilters: []
equalsFilters: []
includeFilters: []
At this point, persistence is broken - and RRDJ4 seems to save nothing.
Now the documentation continuously refers to persist config files “Persistence Strategies are configured in a file named .persist, stored in $OPENHAB_CONF/persistence. Replace “persistenceservice” with the name of your persistence add-on (e.g. rrd4j.persist).”. However, these steps to do create such a file.
If I now go back into the UI and “Edit persistence configuration” I can add a configuration for a group, restart openhab and I seem to be able to get persistence working again… All without .persist files.
configurations:
- items:
- Local_Sun*
strategies:
- everyChange
filters: []
cronStrategies:
- name: everyMinute
cronExpression: 0 * * ? * *
- name: everyHour
cronExpression: 0 0 * * * ?
- name: everyDay
cronExpression: 0 0 0 * * ?
defaultStrategies:
- everyChange
thresholdFilters: []
timeFilters: []
equalsFilters: []
includeFilters: []
The documentation seems to refer to similar config but .persist files must have different formats and rules than the UI configured config but the docs don’t make this clear.
Now if I would like to have my /userdata/jsondb/org.openhab.core.persistence.PersistenceServiceConfiguration.json exactly replicate the default persistence the thing to do would be to add * for all items like the documentation suggest right? However, if I add * for items in the code (I can’t select in UI) it does not let me save - it gives me a validation error
Produces error on save: “YAMLReferenceError: Aliased anchor not found:”
configurations:
- items:
- *
strategies:
- everyChange
filters: []
cronStrategies:
- name: everyMinute
cronExpression: 0 * * ? * *
- name: everyHour
cronExpression: 0 0 * * * ?
- name: everyDay
cronExpression: 0 0 0 * * ?
defaultStrategies:
- everyChange
thresholdFilters: []
timeFilters: []
equalsFilters: []
includeFilters: []
The alternative seems to be to select every item group but if I create new groups they won’t persist by default.
Questions I have
- Is there a way to replicate the default persistence via the UI config for RRDJ4? I can’t seem to find a way
- Is the documentation up-to-date? Should advice to beginners be use UI based config only if you want to get specific about each item/group. If you want to express default persistence for all items, you must use .persist files, not the UI config?
The ultimately goal I’m trying to achieve here is
- Retain RRDJ4 default persistence strategy and approach for all existing items, and all new items I will ever add - once I get that working, I want to then add
- MapDB persistence for specific string items that I want restored on startup.
MapDB config is in the same file as RRDJ4 config (/userdata/jsondb/org.openhab.core.persistence.PersistenceServiceConfiguration.json) so I’m getting stuck at point 1.
Thanks for your help!