Hello Dominik,
I think that your rule in post 14 was quite correct, except the +windowName as @hr_2 pointed out and split("_") as @vzorglub flagged. But the issue is that in post 21 you replaced val windowName by var windowName. That was the meaning of the cryptic sentence of @hr_2 : “Cannot refer to the non-final variable windowName inside a lambda expression”. val introduces a final variable and var a non-final variable (cf. : http://www.eclipse.org/xtend/documentation/203_xtend_expressions.html#variable-declaration ).
I made a little simulation to test your rule :
Items :
Group gH_Contact_global
Group gH_Rolladen_wz_switch
Contact EG_wz_fk_tuer "Fensterkontakt Wohnzimmertür" (gH_Contact_global)
Contact OG1_sz_fk_tuer "Fensterkontakt Schlafzimmertür" (gH_Contact_global)
Contact OG1_az_fk_tuer "Fensterkontakt Ankleidezimmertür" (gH_Contact_global)
Rollershutter EG_wz_rs_tuer "Rollade Wohnzimer Tür" (gEG_Rolladen_wz,gH_Rolladen_wz_switch)
Rollershutter OG1_sz_rs_tuer "Rollade Schlafzimmertür" (gH_Rolladen_wz_switch)
Rollershutter OG1_az_rs_tuer "Rollade Ankleidezimmertür" (gH_Rolladen_wz_switch)
Switch EG_wz_switch_3_long
Rules:
rule "Test_ON (prepares simulation)"
when
Item Declenche_switch changed to ON
then
EG_wz_switch_3_long.postUpdate(ON)
EG_wz_fk_tuer.postUpdate(CLOSED)
OG1_sz_fk_tuer.postUpdate(OPEN)
OG1_az_fk_tuer.postUpdate(CLOSED)
EG_wz_rs_tuer.postUpdate(UP)
OG1_sz_rs_tuer.postUpdate(UP)
OG1_az_rs_tuer.postUpdate(UP)
end
rule "Test_OFF"
when
Item Declenche_switch changed to OFF
then
EG_wz_switch_3_long.postUpdate(OFF)
end
rule "Rolladen Wohnzimmer schliessen"
when
Item EG_wz_switch_3_long received update OFF
then
gH_Rolladen_wz_switch.members.forEach[rs|
var nameParts = rs.name.split("_")
val windowName = nameParts.get(0) + "_" + nameParts.get(1) + "_fk_" + nameParts.get(3)
logInfo("DEBUG", "windowname = " + windowName)
//logInfo ("Fensterkontakt der offen is:", windowName)
if (gH_Contact_global.members.filter [fk | fk.name == windowName].head.state != OPEN){
logInfo("DEBUG", "Fensterkontakt " + windowName + " is CLOSED")
postUpdate(rs,DOWN)
}
else {
logInfo("DEBUG", "Fensterkontakt " + windowName + " is OPEN")
}]
end
Results (when Declenche_switch is moved to OFF on my sitemap):
2018-03-27 17:51:50.271 [INFO ] [eclipse.smarthome.model.script.DEBUG] - windowname = OG1_sz_fk_tuer
2018-03-27 17:51:50.276 [INFO ] [eclipse.smarthome.model.script.DEBUG] - Fensterkontakt OG1_sz_fk_tuer is OPEN
2018-03-27 17:51:50.279 [INFO ] [eclipse.smarthome.model.script.DEBUG] - windowname = OG1_az_fk_tuer
2018-03-27 17:51:50.283 [INFO ] [eclipse.smarthome.model.script.DEBUG] - Fensterkontakt OG1_az_fk_tuer is CLOSED
2018-03-27 17:51:50.288 [INFO ] [eclipse.smarthome.model.script.DEBUG] - windowname = EG_wz_fk_tuer
2018-03-27 17:51:50.291 [INFO ] [eclipse.smarthome.model.script.DEBUG] - Fensterkontakt EG_wz_fk_tuer is CLOSED
events.log:
2018-03-27 17:51:50.266 [ItemStateChangedEvent ] - EG_wz_switch_3_long changed from ON to OFF
2018-03-27 17:51:50.286 [ItemStateChangedEvent ] - OG1_az_rs_tuer changed from 0 to 100
2018-03-27 17:51:50.294 [ItemStateChangedEvent ] - EG_wz_rs_tuer changed from 0 to 100
You can see that the two contacts OG1_az_rs_tuer and EG_wz_rs_tuer receive the command DOWN (=100).
Another thing to take care of :
in your post 33, I don’t see gH_Rolladen_wz_switch as a group name the Rollershutters belong to :
Rollershutter EG_az_rs_fenster "Rollade Spielzimmer" <rollershutter> (gEG_az,gEG_Rolladen_wz) ["Lighting"] {channel="homematic:HG-HM-LC-Bl1PBU-FM:1#LEVEL"}
Rollershutter EG_wz_rs_seite "Rollade Wohnzimmer Seite" <rollershutter> (gEG_wz,gEG_Rolladen_wz) ["Lighting"] {channel="homematic:HG-HM-LC-Bl1PBU-FM:1#LEVEL"}
Rollershutter EG_wz_rs_tuer "Rollade Wohnzimer Tür" <rollershutter> (gEG_wz,gEG_Rolladen_wz) ["Lighting"] {channel="homematic:HG-HM-LC-Bl1PBU-FM:1#LEVEL"`
Best regards.
Edit: I left the postUpdate for the simulation, but
sendCommand(rs,DOWN)
is probably necessary.