OpenHab2 Rules

Thats interesting… Im using openhab2 so im not sure where the openhab.cfg is located or if i need to create one. Also im running the new rule engine that you can install from paperui

Doh, sorry, I did see the OH2 references. In OH2 you can make a openhab.cfg for legacy binding information, but i’m not sure it would apply for this use-case.

I’ve also never used the experimental rule engine (although it looks like it’d be nice). In fact, i’ve not seen any questions about it before so not sure where to help look either.

shrug

Its actually really easy to use and works well when initalized haha… in windows it worked well and my guess is because the com port was always available right when openhab started.

Since I dont have alot of experience with rules i wouldnt mind trying to setup a few rules the old way… Anybody have some pointers on how to get started… here are the items im trying to control:

PlexTVStatus (Type=StringItem, State=Stopped, Label=Status, Category=video)

zwave_device_9e525cd7_node2_switch_dimmer (Type=DimmerItem, State=100, Label=Standing Lamp, Category=null, Tags=[Lighting])

zwave_device_9e525cd7_node3_switch_dimmer (Type=DimmerItem, State=100, Label=Side Lamp, Category=null, Tags=[Lighting])

Basically when the state of the PlexTVStatus changes to Playing i want the lights to turn off and when the state changes to Stopped then i want them to turn back on… and possibly turn on to like 10% when the state is Paused.

Good starting point are the sample rules:

and the rules wiki page:

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.