Hi,
i have a rule which is looping through a group of window reed contacts:
rule "Fenster Sammelstatus SZ + Ankleide"
when
Item Windows_SZ_Ankleide changed
then
Windows_SZ_Ankleide.members.forEach(contacts|
if (contacts.state == CLOSED) {
postUpdate(Windows_SZ_Ankleide_Sammelstatus, CLOSED)
}
)
Windows_SZ_Ankleide.members.forEach(contacts|
if (contacts.state == OPEN) {
postUpdate(Windows_SZ_Ankleide_Sammelstatus, OPEN)
}
)
end
The thing is when one of the contacts of the group is OPEN the loop should break immediately and send an OPEN via postUpdate. I’ve tried to use a “break” like in a Java loop but this throughs an error.
Any suggestions?
Why don’t using the Group:OR function?
Group:OR(OPEN,CLOSED) Windows_SZ_Ankleide "Es sind Fenster offen [%d]"
The group itself Windows_SZ_Ankleide.state
will stay OPEN as long as there is at least 1 open contact.
As an alternative setup, you could use:
rule "Fenster Sammelstatus SZ + Ankleide"
when
Item Windows_SZ_Ankleide changed
then
if(Windows_SZ_Ankleide.members.filter(contact|contact.state==OPEN).size > 0)
postUpdate(Windows_SZ_Ankleide_Sammelstatus, OPEN)
end
Thx Udo! Will this statement in the *.items config send a OPEN (= 1) state to the KNX GA which is binded to this item?
Group:Contact:OR(OPEN, CLOSED) Windows_SZ_Ankleide "Offene Fenster/ [(%d)]" <contact> {knx="<5/1/1"}
I didn’t try this yet
but you could use a simple rule to send another item instead:
rule "proxy contact group to knx"
when
Item Windows:SZ_Ankleide changed
then
Windows_SZ_Ankleide_proxy.sendCommand(if(Windows_SZ_Ankleide.state == CLOSED)OFF else ON)
end
The simple rule works like a charm 