Paperui rules engine usage

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.
[/quote]

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:

image

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!

Bill

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?

Regards,

Willi

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.

That button makes a REST API call something like this…

http://localhost:8080/rest/rules/9ede01b8-bbb7-43a1-9679-1fad663b7090/runnow

… which executes RuleEngineImpl.runNow(ruleUID, false, null). This then gets down to…

executeActions(rule, false);

… which just executes the rule’s Actions. In your case, this is turning off the soundbar. Even if you have Conditions that aren’t met (you don’t happen to have any), the Actions will still execute. The Triggers are not part of the equation. So, everything appears to be working as expected. :slight_smile:

@5iver Thanks for the explanation. This is making more sense now but if I have to evaluate that the rule should fire only when the Iphone is on then how do I do that because you’re saying that I don’t have the condition defined in my rule to check for the Phone but the when condition isn’t it ensuring that the Phone Channel online has to be online. Is there a way to evaluate Phone Online channel to see if it is True or False?

If your rule is working, then why do you need to evaluate the phone’s state in the Action? I’m thinking there must be some pieces to the puzzle that you have not shared. :slight_smile: Maybe you want to execute the Action from another rule? If so, just add a Condition to the other rule to check if your phone Item’s state.

If you are wanting to evaluate the state of Items in your Action, then you will need to use the ‘execute a given script’ Action, and use JS to add conditional logic to the Action. @rlkoshak has put together a series of posts about using the new rule engine with Paper UI, and I think here may have covered this.