Restore on Startup with MapDB

Hi there,

I use a virtual switch which is defined in the .items file

Switch alarmstill   "stiller Alarm (aus/an)"    <soundvolume_mute>      (gM,gR)     // Silent Alarm

According to my mapdb.persist the state should be restored on startup since the switch is a member of gM group:

Strategies {
	everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
    every15min  : "0 0/15 * * * ?"
	default = everyUpdate
}

Items {
    // persist all items of gM on every change and restore them from the db at startup
    gM* : strategy = every15min, everyChange, restoreOnStartup
}

Today I just came across with an unexpected behavior …

2019-06-18 21:26:50.978 [ome.event.ItemCommandEvent] - Item 'alarmstill' received command ON
2019-06-18 21:26:51.010 [vent.ItemStateChangedEvent] - alarmstill changed from NULL to ON

Why was the initial state of alarmstill NULL - but neither ON nor OFF ?

The state NULL caused another rule not to be triggered:

if(alarmstill.state==ON)

Because all Items initially have the state NULL. During startup, the persistence will restore the Items to the most recent state stored in the database. This will generate a changed event. Depending on timing this could cause Rules to trigger.

That isn’t what appears to be happening here though. How close to startup did these events occur? Is this a brand new Item that hasn’t had a state before?

On an unrelated note, an every15min strategy is pointless when using MapDB.

Thanks for your reply.

openHAB is running for about 4 days.
I didn’t touch the switch since then.

Maybe it could be that it always had the state NULL because I did a new setup of openHAB some weeks ago … could this be the reason?

I think with your strategy mapdb will only record on item changes and since you say you didn’t change the switch since startup it would explain its state.
what’s your settings of persistence in addons.cfg and of org.eclipse.smarthome.persistence:default in runtime.cfg ? Is there another persistence method in use ?

addons.cfg

# A comma-separated list of persistence services to install (e.g. "persistence = rrd4j,jpa")
persistence = mapdb,rrd4j

runtime.cfg

################ PERSISTENCE ####################

#  The persistence service to use if no other is specified.
#
#org.eclipse.smarthome.persistence:default=

In paper-ui:

image