i want to ask each member of a ‘humidity’ group for there state and if the state exceeds a specific value a rule shall switch another item to ON. The name of the other item is defined by the members name.
Items:
Group ghumidity
Number SZ_humidity "SZ [%.1f %%]" <humidity> (ghumidity)
Switch SZ_humidity_warning "[MAP(warnings.map):%s]" <humidity>
Rules:
var humidity_Grenzwert = 70
rule "Warnung Luftfeuchtigkeit über Grenzwert"
when
Time cron "0/5 * * * * ?"
then
ghumidity.members.forEach [i|
if (i.state > humidity_Grenzwert) {
logInfo("Humidity Group", i.name + " beträgt " + i.state.toString + "%");
sendCommand(i.name + "_warning" , ON)
}
]
end
sendCommand(i.name + “_warning” , ON) don’t work. Like you can see above I defined an item for warnings for each member of the group ghumidity.
Is there a possibility to merge the itemsname with the suffix “_warning” from different strings - like sendCommand(i.name + “_warning” , ON)?
As rossko57 indicates, don’t use a cron trigger. Just trigger the Rule when ever one of the humidity Items changes. Then you can issue your warning.
when
Member of ghumidity changed
then
if((triggeringItem.state as Number) > humidity_Grenzwert){
sendCommand(triggeringItem.name+"_warning", "ON")
}
end
Notice the minor changes. The “as Number” may not be required but putting quotes around the ON is required when using the sendCommand Action. It can only accept Strings. As rossko57 indicated, you would have seen errors in the logs.