Groups are super convenient and I wonder if I can also to do what I want with them.
I have this group:
Group:Switch:OR(ON,OFF) presenceFredrik "Fredrik är hemma? [%d]" <man_3> (gPresentPersons,gAnyonePresent)
and the idea is that if even one of the sensors that are members of this group would set it to ON. It works as is should, but the [%d] is a bit unsatisfactory. Is there any way to alter this so that I get a TRUE/FALSE or a switch ON/OFF indication there instead?
Group:Switch:OR(ON,OFF) presenceFredrik "Fredrik är hemma? [%d]" <man_3> (gPresentPersons,gAnyonePresent)
Switch s1 (presenceFredrik)
Switch s2 (presenceFredrik)
Group:String ti "Gruppe Lampen[%s]" <light> //durch die Definition als :String kommt es zu: [ERROR] [rthome.core.library.items.StringItem] - Tried to set invalid state ON on item li of type StringItem, ignoring it
Group ti1 "alle Lampen" //wirkt autom. auf alle Items der Gruppe (%s wird nicht angezeigt, nur ON bzw. OFF)
Group:Switch ti2 //wird intern gebraucht
Switch ti_ALL "alle Lampen" (ti) //wirkt per rule, kann dafür autom. über die Gruppe angezeigt werden
Switch ti_TH "Licht Treppenhaus" <light> (ti,ti1,ti2)
Switch ti_EG "Licht Erdgeschoss" <light> (ti,ti1,ti2)
rules
rule ti2
when
Item ti2 received update
then
logWarn("_","ti2 "+ti2.state.toString)
val x = ti2.members.size
val on = ti2.members.filter[s|s.state==ON ].size
val off= ti2.members.filter[s|s.state==OFF].size
if (on==x) {ti.postUpdate("ON")} else if (off==x) {ti.postUpdate("OFF")} else {
val xx = x-on-off
var y = ""
if (off !=0) {y=y+off+"aus "}
if (xx !=0) {y=y+xx +"n.aus "}
if (on !=0) {y=y+on +"an"}
ti.postUpdate(y)}
// if (on==0) {ti.postUpdate("OFF")} else if (off==0) {ti.postUpdate("ON")} else {ti.postUpdate(off+"aus,"+on+"an")}
// if (on==0) {ti.postUpdate("aus")} else if (off==0) {ti.postUpdate("an")} else {ti.postUpdate(off+"aus,"+on+"an")}
// if (on==0) {ti1.state=OFF} else {ti1.state=ON}
if (off==x) {ti1.state=OFF} else {ti1.state=ON}
if (ti_ALL.state != ti1.state) {ti_ALL.state = ti1.state ti2.postUpdate(ti2.state)}
end
rule ti_ALL
when
Item ti_ALL received command
then
logWarn("_","ti_ALL "+receivedCommand)
if (ti2.state != ti_ALL.state) {sendCommand(ti2,ti_ALL.state.toString)}
end
sitemaps
sitemap _t5 label="_T5" {
Frame{
Group item=presenceFredrik
Switch item=presenceFredrik
Switch item=ti1
Group item=ti
}
}