Rule with group

Hi there,
i am new to openhab. I am switching from fhem to openhab and struggeling a little with some basic rules.

What I did is to notify myself via pushover if a window opens. Therefore I am using a window group.

A rule sets a alarm:
rule “Contact opened - Check for alarm”
Member of gAllContacts changed from CLOSED to OPEN
if(Alarm_Level.state > 0){

Everything, including the notificatin, works as expected. But I don’t know how to identify the window witch generated the event. Probably pretty simple. I just don’t get it. Sure, i could check the state of every member of the group. But that doesn’t necessarily give me the correct result.

Thanks for any ideas!


ok, great! I get that.
Now that I know how to find out what Item caused the action, how can I get that Item by another rule? There are no method parameters or what so ever. So I tried to get the Item into a variable. But that doesen’t seem to work.

Any ideas on that?

The first question is why do you need another Rule?

OH Rules are event driven. When X occurs, do Y. X is the Rule triggers and Y is the Rule body. Using Groups and triggeringItem there really shouldn’t be a need to “call” another Rule to process the event.

If you are trying to treat window contacts different from door contacts, for example, then the better approach would be to set up separate Groups for each group of Contacts and one Rule for each case.

Obviously there are some cases where there might be exceptions to this Rule but with the little amount of detail provided I don’t think they apply.

See the Design Pattern postings for lots of examples for how to best structure your Rules to avoid duplicated code. In particular, Associated Items, Separation of Behavior, Working with Groups in Rules, and DRY, How to Avoid Duplicated Code in Rules.