OpenHab2 Rules

Are you using persistence?

If you set up persistence with restoreOnStartup those Item will be initialized to their previous value when OH starts up instead of Undefined which is why that rule is throwing an error.

Not entirely certain as to why you are seeing the error now and didn’t before, but I believe using persistence in this case is the best answer.

See the following for details:

The New Rule Engine is experimental so there could be some other things going on as well. I still think persistence will address your issue.

Hmm I’ve seen a little about persistence and not sure exactly where to start. Is there any type of persistence that is built-in? Without the need to setup a database?

If you just want to use the last state of your items for restore on startup, mapdb is the easiest to setup:

But it doesn’t provide any history, for that you could use rrd4j. Both create the database automatically, no need to install one.

Perfect for now that’s all I need is mapdb. For openhab2 I installed the persistence extension through paperui and also set mapdb is the default persistence in paperui. Is there anything else I need to do or will it handle all the rest it’s self?

In addition to that you need to create a mapdb.persist file in
/conf/persistence

and

You may persist single items

Items {
        ItemName : strategy = everyChange, restoreOnStartup
}

or groups

Items {
        GroupName* : strategy = everyChange, restoreOnStartup
}

or everything

Items {
        * : strategy = everyChange, restoreOnStartup
}

Then change your switch state so the database gets populated, restart openhab and the switch should have the same state as before the restart

Hey how did you get your Plex entered in on OH2? I have been racking my brain on how to do that. I am not running on a PI but a stand alone server. Any help would be great.

Was having issues with plex as well… this thread helped me…

So I guess the binding is in that post too?

Binding is downloaded from openhab main site. It’s in the main addons download.

I see the one for OH1 but is there a OH2 one or is it one in the same?

Should be the same one.

1 Like

Any update on this ?

In my OH2 i have a mapdb persist file with the following info.

Strategies {
default = everyUpdate
}

Items {
// persist all items on every change and restore them from the db at startup

  • : strategy = everyChange, restoreOnStartup
    }

default=mapdb

I still get Not_Initialised, on every rule, every morning when i log into OH2.

Any help ?

/Robert

That should not be part of your mapdb.persist file. Maybe it is causing problems because it cannot be parsed correctly.

If you want to define a default persistence service edit runtime.cfg to
org.eclipse.smarthome.persistence:default=mapdb or set that via PaperUI oder HABmin.

Thanks i just tried this. I will know by tomorrow if it works :slight_smile:

No luck. I got the same result.

Any other ideas ?

mapdb is showing up as default in the UI, and i have configured the mapdb.persist, as i described in the earlier post.

Some simple rules worked well for me until I updated my Raspberry/openhab2 last week via sudo apt-get update and upgrade. I lost my habpanel settings and rules in Paper UI are not working anymore. Any idea what went wrong?

You need to provide more details if you need help:

Post one of your “simple” rules which are not working anymore
From what build number to what build number did you upgrade?

This is important because there were some breaking changes in the last weeks which could all be related to your problems:

https://community.openhab.org/c/openhab-2/news-important-changes

So you should check if:
Your bindings are still installed
Your things are still there (because of change of mapdb to jsondb)
and a lot of more things.
What are the error outputs of your openhab.log?
Did you already switch to debug mode? If yes, what are the outputs of your openhab.log?

I seem to have solved it. The rules were gone. When I added them again, I named them e.g. “Lights on”. Seems rule names don’t allow spaces. “Lights_on” works.

After the update I also needed to add the z-wave binding again. The serial port for the USB-stick was gone. For several things, the item links were gone.

However, the different “Panel configurations” (not local storage) in habpanel are gone. I wonder were they are saved and if they could be loaded again. But maybe they were just overwritten/deleted through the update.

Agree, same problem here. (But actually just for cron rules)

1 Like