This is my little persistence file - unfortunately not working

Can you help please?

This is my persistence file. I want to store the activation for two dummy switches
in case of a restart or power loss.
Openhab.log is all OK reads the persistence file without errors but the switches are "OFF"
after restart, even I switched them “ON” before restarting the PI3

G11.persist:

Strategies {
default = everyUpdate
}

Items {
AlarmAussen : strategy = everyChange, restoreOnStartup
AlarmInnen : strategy = everyChange, restoreOnStartup
}

Hi Boris,

I’m sorry - I’ve never heard about a persistence service called “G11”.
What’s that?

Cheers,
Marianne

Hi Marianne,

But this is just my file name g11.persist.
Content I have copied 1:1 from openhab documentation, just added my two items.

So should work, but nothing.
No error in openhab.log

Hi,

your persistence file has to reflect the persistence you’re using.
So when using influxdb, you’ll create influxdb.persist. When using MapDB, you’ll use mapdb.persist.

And, of course, you’ll have to install your desired persistence first :slight_smile:

Does that help?

Cheers,
Marianne

Hi Marianne,

Does this mean I have to create as many .persist files as switches I want to persist?
E.g. I do have a dummy switch in my item file in order to activate AlarmAussen. The switch is also called AlarmAussen.
So when I understand you correctly I need to create a AlarmAussen.persist now?
And further files as many switches I want to persist?
And what do you mean with I have to install your desired persistence first?

No, you first need to decide which persistence service you want to use. (As Marianne pointed out)
In my case, i’m using MySQL and therefore i have got one persistence file called mysql.persist:

Strategies {
	default = everyUpdate
}

Items {
	gPersistence* : strategy = everyChange, restoreOnStartup
	gPersistence  : strategy = everyChange, restoreOnStartup
}

In order not to write a line for each item and on the other hand to be able to choose which items needs to be added to persistence, i’ve created a group gPersistence and with the first line:

gPersistence* : strategy = everyChange, restoreOnStartup

I’m adding all items within this group to the persistence service.
To be honest, i forgot why i also need the second line (since it only stores the state of the group itself) but i can remember that i have had problems without it

Hi Boris,

now, question should be: what kind of persistence do you want to use?
Regarding your persistence config, something like MapDB would be suitable in your case; see https://docs.openhab.org/addons/persistence.html.
So navigate through PaperUI -> Addons -> Persistence and install MapDB with a click on INSTALL.
When it’s successfully installed, take your G11.persist and rename it to mapdb.persist(=> It has to be in $CONFIGDIR/persistence!).

Contents of your config file seems good to me. In case of doubt put OH2 in DEBUG mode, and you’ll see whenever a value is persisted.

And please read the docs - copy and paste seems not to be sufficient :slight_smile:

Cheers,
Marianne

1 Like

Hi Marianne,

This sounds reasonable for me, I will try that. Just for interest what is MapDB and why is this the right one for my case, sorry I can’t really follow to far in the specific details here… I couldn’t follow that piece of documentation, but doesn’t matter I just would like to have a possibility to protect settings for an alarm environment and this is quite important when e.g. power off or something else.

Thanks a lot

Hi Boris,

your config pretends that

  • you want to save everyChange and
  • you want to restore on startup

That’s what MapDB is initially made for. It only (and solely) persists one state for one item. That makes it fast, and it does not need much resources. But on the other hand, you’re not able to “time travel” in your persisted data.

The persistence service of your choice always depends on what’s your goal; that why I recommend you to read more docs :wink:

Cheers,
Marianne

Ok Ok ich glaube es, schließlich kommen wir beide aus dem schönen Saarland :grinning:

:scream: Wie gruselig ist das nun bitte?! :joy:

Wieso ich sah zufällig in deinem Profil Saarland :grinning: da komme ich her…
Auch wenn momentan in Spanien, wegen dem Wetter…

Hi Marianne,

I followed your instructions activated the MapDB persitance but unfortunately Openhab does not record or remember the switch settings for the two items in my mapdb.persist file, placed it in /openhab2/persistence folder.
The two items are defined and visible in BasicUI, when I switch these ON (means Alarm activated) I would expect that when Power off and on again, I see my two switches “ON” but it isn’t, they are on “OFF” after restart.

How can I check what´s wrong?
What log will show me what´s wrong?
Please keep in mind I am not so familiar with Linux…

Thanks a lot

2 things:

  1. are those switches part of gPresistence group?
  2. did you try restarting the server?
  3. did you stare at the log to see if it loads the persisted value? (there is some delay) it will not instantaneously start with the persisted value, but rather load with undefined, and then populate the persistence record.
    If in the mean time you have a system stared rule and/or a real time new update, the persistence value might not have a chance to show up.

Does that make sense or should I try to re-explain it better?

and now I have added the following:

org.eclipse.smarthome.persistence:default=mapdb

in the file services/runtime.cfg

and it isn´t working at all cannot access any UI,
PI green LED is flickering a lot maybe an update, I´ll check and come back

Hi Nadir
No I still just use the two items as shown above for testing purposes.
Yes I restarted and now the PI is updating Openhab
Which log should show me the persisted values?

And i also added that
org.eclipse.smarthome.persistence:default=mapdb

in the file services/runtime.cfg because it wasn´t there