Installating acting weird on reload

I’ve got different rules to manage my hardware (fe knx, zwave…). I’ve got rules to put my house in a sleep mode, rules to trigger log alerts when things happen… Everything works great, except a reload of openhab.

When I reload openhab, different lights go on, pushover messages are being send… It’s like different statusses are being switched over and so.
Is there a way to ‘delay’ rules in triggering actions? Or can something else be done to avoid this behavoir?

Are you using persistence with restoreOnStartup?

Don’t think so. When it’s not by default, I’m not using it. :blush:
For the moment, I’ve got just (?) the persistence mysql and rrd4j. At least those are present in de persistence folder.

It’s not yet clear to me how this persistency flow work, Will have a look how this (should) work. Testing will be for tomorrow. My baby girl is sleeping, and don’t want to wake her with bringing the light accidently on.

When you restart openHAB all your Items get initialized to UNDEFINED. Then as your bindings come online and events happen those Items get populated with a “real” state. If you have rules that trigger on updates, commands, or changes, those rules will be triggered as openHAB restarts (or upon editing and saving an .items file).

If you use persistence with restoreOnStartup, your Items will instead be initialized to what ever their most recent value was when openHAB was last running. This initialization does not result in any events so Rules don’t get triggered. In short, your Items will come up with a sane and real value instead of UNDEFINED.

See the following for my recommended Persistence configuration.

1 Like

ok, think I’ve got it implemented.

In mapdb.persist:

Strategies {
default = everyUpdate
}

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

and in rrd4j

Items {
// persist everything when the value is updated, just a default, and restore them from database on startup
* : strategy = everyChange, everyUpdate, restoreOnStartup, everyMinute

Should this be enough?
What’s the best way to have a look in the db if it’s in there? Or if it’s been updated?

You only need restoreOnStartup on one of your persist files. I recommend keeping it in your MapDB one.

Have you installed the MapDB and rrd4j addons?

Which version of openHAB are you using and how did you install it and on what OS? All of that can change where the DB files are created. But if you don’t see errors in your openhab.log when openHAB reboots you should be fine.

You should be able to delete it yourself, though that may just be that case with postings, not threads. You can edit it though, delete the contents and point it to the “real” posting.

NOTE: This reply is on the wrong thread.

Sorry for the late follow up. My girlfriend is working nights, so she’s sleeping overday, my 2year old girl sleeps at night. So give me not much room to play around with it all. Is a bit annoying when I restart the server, and lights start flashing and so. :blush:


I added the mapdb.persist (see below), but it’s not running like it should. When I restart openhab, still get flashing lights and so when the rules are being read. Don’t I need to add something in the rules as well?

I’ve also noticed that my graphs aren’t being upgraded anymore. Just flat lines in there after I’ve added mapdb. If I remember well, mysql was necesarry for the rrd4j. Is it possible that there’s a conflicht between mysql and mapdb? Do I need them both, or can I remove the mysql?

In my log, i’m getting:

openhab.log:2016-09-29 19:57:46.388 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'mapdb.persist’
2016-09-29 19:57:46.436 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'mysql.persist’
openhab.log:2016-09-29 19:57:46.436 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'mysql.persist’
openhab.log:2016-09-29 19:57:58.986 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'mysql’
openhab.log:2016-09-29 19:57:59.051 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'mysql’
openhab.log:2016-09-29 19:57:59.692 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'mysql’
openhab.log:2016-09-29 19:57:59.694 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'mysql’
openhab.log:2016-09-29 19:57:59.696 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name 'mysql’
openhab.log:2016-09-29 19:57:59.695 [WARN ] [.o.c.p.e.PersistenceExtensions] - There is no queryable persistence service registered with the name ‘mysql’


Some additional info

Openhab version: 1
org.openhab.persistence.mysql: 1.8.3
org.openhab.persistence.mapdb: 1.8.3

Existing persistence files:

mapdb.persist*
mysql.persist*
rrd4j.persist

in mapdb:

Strategies {
        default = everyUpdate
}

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

in mysql:

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour       : "0 0 * * * ?"
        everyDay        : "0 0 0 * * ?"
        default = everyChange
}

Items {
        * : strategy = everyChange, everyHour, everyDay, restoreOnStartup
}

And in rrd4

Strategies {
        everyMinute : "0 * * * * ?"
        everyHour       : "0 0 * * * ?"
        everyDay        : "0 0 0 * * ?"
        default = everyChange
}


Items {
        // persist everything when the value is updated, just a default, and restore them from database on startup
        * : strategy = everyChange, everyUpdate, restoreOnStartup, everyMinute


        // next we define specific strategies of everyHour for anything in the Temperature group, and and every minute for Humidity
        WO_tem* : strategy = everyMinute
        WO_hel* : strategy = everyMinute
        WO_bat* : strategy = everyMinute
        WO_verm* : strategy = everyMinute
        WO_verb* : strategy = everyMinute
        AT_tem* : strategy = everyMinute
        AT_hel* : strategy = everyMinute
        AT_bat* : strategy = everyMinute
        AT_verm* : strategy = everyMinute
        AT_verb* : strategy = everyMinute
        ALL_tem* : strategy = everyMinute
        ALL_hel* : strategy = everyMinute
        ALL_bat* : strategy = everyMinute
        ALL_verm* : strategy = everyMinute
        ALL_verb* : strategy = everyMinute
}

Not for restoreOnStartup. That happens automatically before rules start running.

Confusion here. MySQL is an alternative to rrd4j. Both are separate databases and do not depend upon each other. There isn’t a conflict but you may need to go in to your openhab.cfg and set your default persistence to whatever DB you are generating the charts from.

The bottom line is you do not need both rrd4j and MySQL and can remove MySQL if you don’t use it. However, in your logs I see no reference to rrd4j, are you sure you have that installed? You also don’t reference having rrd4j installed. How are you trying to generate these charts?

Is this correct? As I remember it (it’s been a while since I last restarted so my memory may not serve me well on this occasion) the restoreOnStartup function actually did sort of a postupdate and this indeed triggered some of my rules (that reacts to updates of changes in state).

If this is not the case, i.e. the restoreOnStartup is actually used during the initialization of the items states, then this sounds very good (and possibly means that I will have to reconsider the source of the annoying startup behavior that I have experienced before).

That is a good point. I think I remember reading that was the case but
can’t find it anywhere. I never see restoreOnStartup trigger errors because
in OH 1 I had the timing set so rules don’t load until well after items and
persistence. In OH 2 this ordering seems to happen naturally.

Logically it makes sense in my mind that restoreOnStartup shouldn’t trigger
rules. But I might just have set my self up where I would never see
otherwise.

An easy test would be to modify the polling period so errors load before
persistence and then to where it loads after. If restoreOnStartup sure
trigger rules, you should see that in the former and not in the latter.