Paperui rules engine usage

I have begun to create my rules on openhabian with the paperui rules engine addon.

I have been successful with triggering things on/off. But, the zwave devices I’m using are dim-able.

But there doesn’t seem to be an option for setting the level, only on/off.

I also have the mqtt binding set up and can receive info from subscriptions. In one case a number representing water pressure, the other text indicating that motion has been sensed in the driveway.

But, what do I choose in the rules engine gui? I see the mqtt item, but the choices of what was received are Down, Closed, On/Off… Are received mqtt messages seen as state changes? How do I base login on them? Or, do I need to switch to config files to get that complicated?


The Next Gen Rules Engine is not yet ready for prime time so I’ll add caution that not everything is complete or working yet and there is virtually no documentation for it yet. You are largely on your own when using this rule engine for now. The docs sate that support in OH 2 for this rules engine is experimental.

Your question also belies some misunderstanding about some of the parts of OH and how they work together.

Rule only care about Items. The bindings the Items are connected to (or not) is invisible to the Rules. The Rules don’t know the difference between a Switch Item linked to a zwave channel compared to a Switch Item bound to the MQTT binding. All the Rules see is a Switch Item.

Switch Items can only receive ON/OFF as commands. That’s it. So if I had to guess, I’d say that the Item you are trying to trigger off of is a Switch Item.

If you want to set the level, you need to create a Dimmer Item (linked to the Dimmer Channel of the zwave Thing). A Dimmer Item can receive ON/OFF, INCREASE/DECREASE, and Percent (number between 0 and 100) as a command.

I don’t know the answers to your remaining questions. It should be possible to trigger Rules like you want in the NG Rules Engine, but I couldn’t tell you how.

Yes, I read that and it was noted in at least one youtube video talking about the rule engine.

Very likely true and this is my first foray into rules. That said, I should have been referring to items not things.

My questions actually mixed two use cases I am attempting to create to learn.

I have a zwave switch (lets call it S1) and a zwave dimmer (call it D1). The switch item is a switch and I selected it as target of the “if”. I.e. IF S1 is on. In the then clause I select D1 as the target to be controlled. The options given to control are On/Off, Down, Close. It is a dimmer item and can be dimmed, for example in habpanel with a slider connected to the item.

The second case, the mqtt item is sending pressure data (in habpanel a gauge or dummy widget show the value change each time the mqtt topic is sent.

If a rule can only see the mqtt item as switch, how does one create a rule, for example: “if the pressure is above x, turn on the red light”? Does one need to put that logic in the sensor and have it publish an on message?

It doesn’t. It sees the Item for what it is. If it is a Number Item then it sees the Item as a Number Items. If it is a Dimmer it sees it as a Dimmer Item. If it is a DateTime, it sees it as a DateTime Item.

What it doesn’t see is what binding or Channel that the Item is linked/bound to.

I can’t answer that except to say perhaps Dimmers are not yet fully supported yet. Down and Close are what I would expect for a Rollershutter Item, not a Dimmer.

Presumably the Item is a Number Item so you should be able to trigger the Rule on changes to the Item, the but only if section to test for > x and the then section turn on the light.

Ok, so if the mqtt item is a string then a compare to a string would be possible?

As for the dimmers, these are the NZW39 which has been updated in snapshot. So it’s likely the definition is not complete yet…

You can’t use the numerical > operator with a String. If it is returning a numerical value, why not use a Number Item?

That is irrelevant. The Item is a Dimmer Item and that is all that the Rules sees. It has no knowledge of the fact that it is linked to a channel representing an NZW39 or anything else. It could be linked to or bound to anything, any binding, any Channel or nothing at all and as far as the Rule is concerned there is no difference.

A Dimmer Item works the same in all cases.

Umm…the example I used did state it was sending a numeric. But, I have several mqtt publishers and not all send numeric values. Thus I mused about how to compare strings.

That is irrelevant. The Item is a Dimmer Item and that is all that the Rules sees. It has no knowledge of the fact that it is linked to a channel representing an NZW39 or anything else. It could be linked to or bound to anything, any binding, any Channel or nothing at all and as far as the Rule is concerned there is no difference.

A Dimmer Item works the same in all cases.

So, the rule engine is not handling dimmers correctly? Because, the item is a dimmer and I get On, Off, Close, and Down.

You can use equals with Strings. That is about it in the only if section of the rule.

That’s my guess.

For all of the state and command boxes you can type in any arbitrary value that you’d like to compare against / send. So for example if I want to dim my lights to 50% I’d do the following in the action section:


Hope this helps, tested on 2.3 release build.

hmm…ok, that seems to work.

But, once the command is entered it won’t let me change the value, for instance if I enter 50 the first time in this dialog then it will set 50%.

But if I hit the gear icon and change it to 100, then hit the check mark. A pop says rule changed, but when triggered it still goes to 50%.

I tried deleting the then clause and re adding it, but it still goes to 50%.

Hi @drmarco,

I’ve been spending time learning about how the new rule engine works lately, and have discovered (like you) that there are some rough edges…

One or two suggestions:

  1. check the state of your rules directly by accessing http://your-openhab-site/rest/rules - I’ve noticed that there are times when paperui doesn’t quite reflect the current state of things. It’s data in JSON format, but you should be able to get the idea of whether your changes have been saved.

  2. You might try restarting OpenHAB in order to get the rules engine to re-read all of the rules.

Hope this helps!


Hello Rich,

run the experimental rules for a while now. Actually use openHAB2.4.0 build #1346 on Windows10. #1346 was the first build for me where the rules have been running after a restart of openHAB without any additional interaction.

Before i had to either disable/enable all rules or to start each rule in order to make them running. But for the next higher build i have been back to the old behavior. Thus is stay with #1346 for now.

Can you give me a hint what i probably do wrong updating or where a feedback to the programmers could be placed?



I think you can file an issue at the ESH GitHub repo.

Hi guys, I am trying to use my Phone for presence but it looks like the rule for some reason isn’t picking up if the phone is on or not. In the HabPanel when the the phone is off it shows that it is off but the rules is bypassing it during execution. I have even tired with experimental rule engine and it the online channel doesn’t work.

I am using the following item network:pingdevice:ebf1f25f:online and using the rule that if the state of Online channel is ON or OFF then do something but looks like the condition is always bypassed and the action that I am doing happens. For testing, I was trying to see if the phone goes offline/off then turn a light off. Even with Rules Engine when I execute the rule the light always goes off.
The rule engine generally works for other rules. For example, if a Soundbar goes off then turn off the thermostat this works great.
Any ideas what am I am doing wrong with the phone online channel?

The Channel trigger Trigger is for events from a Trigger Channel. The Network binding does not list any for the online Channel. In comparison, the Astro binding lists some. You’ll need to link an Item to the Channel, then setup the rule to trigger on Item state changes or updates.

BTW, you should really have started a new topic for this. :wink:

Thanks for the update. I think I am bit confused, so with the link of item with channel can I use Network Binding or do I still need Astro?

Here’s my item that is linked to a channel so it should work

Switch X_Iphone { channel=“network:pingdevice:4a42a4a0:online” }
would this work?

Network. Just use that Item for the trigger and it should work.

@5iver So i tried the rule again when item state update and if network:pingdevice:4a42a4a0:online goes off then turn the soundsystem off. It worked first when my Phone went offline. However, I retested it again while my fone was still off and by executing the rule it again turned off my soundbar. Why it is bypassing the Phone logic?

I did try this with Rules Engine. Seems like I am again doing something basic mistake.
Any help would be appreciated.

Running the rule from Paper UI will just run the Action, which I believe is to turn off the soundbar. So, I think everything is working as it should be. What were you expecting it to do? Please post screenshots of the trigger and action (and condition, if there is one).

@5iver I think it is working fine but I’d like a validation. So when the Phone goes off the Soundbar is turned off and I think the rule is working fine. However, in the third screenshot if I click the play/execute button then at that time if the Phone is still on then even the Soundbar goes off. I was hoping that by manually executing it the condition should be checked first but if that is not the case then I think we are ok.

Also if I need to combine two phones then do I have to create a group switch and then use it? for some reason in my openhab version, I don’t see Items and I am not sure how I can link who Items together to put the AND condition to see if Phone 1 and Phone 2 both off then turn the soundbar off.