My transition to openhab2 has hit a roadblock getting persistence services to work.
I have mapdb installed (and running) and set as the default.
the mapdb.persist file reads:
Items {
// persist all items once a day and on every change and restore them from the db at startup
startpersist* : strategy = everyChange, restoreOnStartup
}
I then have a bunch of items in the (startpersist) group.
In openhab 1.8 this worked fine. However in 2.0 my items are not being persisted. I see no errors in the log. Not sure how to turn on debug logging for mapdb - if anyone knows how to do that then that would be really helpful
Thanks - I now have debug logging working. Unfortunately that gives no hint of what is wrong - the logs look fine as I start, stop and restart openhab2, although I would think I’d see log entries as items change and there don’t seem to be any:
I remember reading somewhere that a “Strategy” has to be defined, regardless of using it or not, so try to change your file to:
Strategies {
default = everyUpdate
}
Items {
// persist all items once a day and on every change and restore them from the db at startup
startpersist* : strategy = everyChange, restoreOnStartup
}
I’m trying to use mapdb persistence, but my virtual buttons keep turning off.
I have this in my runtime.cfg:
org.eclipse.smarthome.persistence:default=mapdb
This is my mydb.persist:
Strategies {
default = everyUpdate
}
Items {
// persist all items once a day and on every change and restore them from the db at startup
StartPersist* : strategy = everyChange, restoreOnStartup
}
Looks all good to me.
Do you have any errors when saving your persist config file in openhab.log?
You should only see something like Refreshing model 'mydb.persist'
Then I have no idea what is wrong.
Before restarting openHAB, did you switch your virtual items several times?
The first trigger will be from null to ON or OFF, maybe that one is not persisted. A second trigger then should store the actual state on everyChange.
Hmm, that still didn’t work. I can see the virtuals in the log being set to OFF and ON, but after I reboot, it still doesn’t keep the switches set to ON.
I have serious issues getting this to work as well.
I installed it via the addons.cfg where i added mapdb to the persistence line.
Also i modified the runtime.cfg to contain: org.eclipse.smarthome.persistence:default=mapdb
After a restart the mapdb.cfg-File is generated but the mapdb.perist is not.
Only after i deleted the mapdb.config file from the user-folder and reinstalled again it worked.
(strange behaviour though …).
now when i store a value via rest for example i get a log message that sais: stored.
but if i restart now it does not recover the old state but says NULL …
is this the same issue described here?
I’d like to try the fix but i don’t know where to copy the files to.
I am trying to implement the persistence without succes.
Step followed:
mapdb installed in PAPER UI
file runtime.cfg added the org.eclipse.smarthome.persistence:default=mapdb
rule within mapdb.persist file. Is everyUpdate or everyChange?
Strategies {
default = everyUpdate
}
Items {
// persist all items once a day and on every change and restore them from the db at startup
StartPersist* : strategy = everyChange, restoreOnStartup
}
I have tried as well that without success. All switches are in NULL.
And the more curiouse thing is that I have a sonoff DUAL where the status is ON and OFF, and I see properly the status in the sitemap, but other sonoff bassic which is in ON, the actual status is NULL in sitemap, should be ON. The rest os switches are NULL
I have restarted with sudo systemctl restart openhab2.service
Any suggestion? Better if I work with rules?
Thank you.
I have solved my issue after restart with the NULL status, with some rules. because mapdb did not work for me. So I used the HTTP binding, easier to check up the POWER of each switch
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
16
Hi
I’m trying my hand at a persistence service now too.
Do I need to “install” anything OUTSIDE of openHAB2 to get mapDB working?
From everything that I can find regarding mapDB with openHAB2, I “think” I only have to add the mapDB persistence service from within PaperUI, then set the default DB in configuration/services and add a mapdb.persist file.
BUT… that all seems FAR too simple.
The mapdb.persist file is loaded…
Strategies {
default = everyUpdate
}
Items {
// persist all items once a day and on every change and restore them from the db at startup
StartPersist* : strategy = everyChange, restoreOnStartup
}
and I can see mapdb-1.0.9.jar in /usr/share/openhab2/runtime/system/org/mapdb/mapdb/1.0.9
Where would I see the log entries for each the the item is persisted?
(For example, I can’t see anything in /var/log/openhab2/openhab.log or /var/log/openhab2/events.log )
Note that with MapDB only the last state is persisted, there are no more historic states:
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
18
Thanks for your uber fast response.
I would have happily waited a few days
That’s fine by me, I only want to restore things like radio station choices and step durations (that are stored in items)
Thanks
1 Like
MDAR
(Stuart Hanlon, UK importer of Velbus hardware)
19
Hi
Thanks for the pointers
That really helps me understand.
I’ve looked at the rest API and I can see I do have a persistence service now
But either I’m missing something, or I’ve done something wrong, as I can’t see the last state.
Unlike your example that clearly shows up
“time”: 1549781038612,
“state”: “OFF”
FYI
I did toggle the DiningRoom light a couple of times before I queried the rest API
Do I have to assign the items I would like persisting to a group of some kind?
My understanding of the mapdb.persist file is that it saves everything… (Not what I need, but I thought that would be a good starting point)
GROUPS…!!!.
I hadn’t assigned the items I wanted persisting to a GROUP >>>>
Items {
// persist all items once a day and on every change and restore them from the db at startup
StartPersist* : strategy = everyChange, restoreOnStartup
}
where StartPersist is the start of the name of the group that I had to assign.
(In theory, I guess I could have groups named “StartPersist” / “StartPersistLounge” / “StartPersistOutdoor” and so on.