Paperui rules engine usage

I have created them in Paper UI but I have simple mode turned off or either on and I don’t see the option to add a parent group. I only see things with linked channels. I dont see items and if I turn that mode on then I see items but it messes up some other config. Do you have the sample code for the things file?

If you have Simple Mode turned on, you will need to turn it off to edit your Items, because they will not be visible until you do. You should be able to turn off Simple Mode, edit your Items, and then turn it back on. If you choose to use an Items file, you will need to delete the phone Items in Paper UI, which will also require you to turn off simple mode.

Please provide more details on what configuration is messed up when you turn off Simple Mode. Maybe there is a bug. IMO, Simple Mode causes more issues than it resolves. :wink:

There is no Things file needed… it is an Items file, and there are examples in the documentation I linked to.

Last time when I changed the mode my Nest had stopped working and I had to reconfigure it. But you’re right it is easy with Items tab available. Let me try and I’ll provide the results.

Okie so I did create a Group switch manually by going to Items file then I turned the simple mode off and now I see Items. I went to the item to update the parent group and the field is disabled.

Something isn’t right, even I deleted and recreated my Phone and then when I tried to add the group it never saved it.

Have you created the group Items?

I created a group item in items file like this.

Group:Switch:AND(OFF,ON) gPhone “Phones [MAP(presence.map):%s]”

Delete it and create it in Paper UI… that way you will have all your Items in one place. You probably have an error in your log, since you probably don’t have the MAP transformation service or a presence.map file. Due to the error, the group would have not been created, which explains why you can’t add the phone Items to it.

Success, I tried it with PaperUI and I am able to create it. Looks good so far.

For MAP transformation service or a presence map file. What has to be in those?

To start with, nothing. You could add these in later. Remove from the definition.

Also for the group to check if both Phones are off which function should work?

As in how do you map with the following

The first one.

and UNDEF.

:+1 I hate simple mode. I spend more time helping people figure out problems caused by their use of Simple Mode than almost anything else.

In more expanded English:

  • All ON → ON else OFF | If all members of the Group are ON, the Group state will be ON. In all other cases the Group will be OFF.
  • All ON → OFF else ON | If all members of the Group are ON, the Group state will be OFF. In all other cases the Group witll be ON.

and so on.

1 Like

@5iver Okie so I have got two things as my two phones, I have linked online items with the phones, the items are part of the parent group switch, the parent group switch item has the logic of All ON --> ON else OFF and still the rule is not firing when both phones are disconnected from wifi.
Here are the screenshots

Rules won’t trigger on ItemUpdateEventTrigger when group members update or change. Use the item changed trigger, which is really the only time you’d want the rule to trigger.

@5iver Thank you so much for the support, the rules are working as expected now. I am using all off -> OFF else ON and it checks for both Phones and if they are off then it sends the command to turn the soundbar off.

I was wondering if I need to put some delays etc then for that I may have to go for command prompt and have to update the rule in the rule files because PaperUI rules engine doesn’t support that.

java.lang.Thread.sleep(1000);

It’s supported.

Thanks for the update. One quick thing though, if I have created a rule from Paper UI and in order to add java.lang.Thread.sleep(1000); I might have to do it from command prompt right? but since the rule was created from Paper UI so I don’t find it in the rules folder.

Rich is speaking of the scripted Action. Your whole Action (then then part) can be in Javascript. But IMO at that point, you should just write the whole rule in JS, or Jython, or Groovy, or the Rules DSL. Have you tried changing the settings in the network binding? IIRC, you can set the poll interval and a retry count, which may add the delay your looking for.

Thanks for the update, seems like I’ll have to explore a lot of this to learn more.

Here’s an achievement that I did using the Rules Engine.

With the gPhones group “If Item State Changes” and with the condition “If previous state is ON and if next state is OFF” then I am executing this condition and it seems to be working perfect. Looks like you can pass values in the command as long as the item is capable enough to accept those.