Hi community,
I ported my OH 1.8 configuration to OH 2 and most rules just worked the same way.
For a rule that counts the number of open windows, I can’t figure out how to set it up.
Contact items use the knx binding and are all members of group “gWindows”.
The rule is:
rule offeneFenster
when
Item gWindows received update
then
val StringBuilder wc = new StringBuilder()
gWindows?.members.forEach[curWindow|
if((curWindow.state as OpenClosedType).equals(OPEN)) {
wc.append("1")
}
]
val openWindows = wc.length()
FensterOffen.postUpdate(openWindows)
end
I also tried the filter method instead of counting the stringbuilder, but the results were the same:
val Number ow = gWindows.members.filter[w | w.state as OpenClosedType != CLOSED].size
To compare the values, I tried ==, !=, .equals, comparing the string after using w.state.toString() - nothing works.
I have a similar rule for lights which runs on Switch items and worked without any change in OH2.
Does anyone have an idea how I can get the rule to work?
Thanks
Daniel