[SOLVED] Merge item.name by different strings

Hey Openhab community - I need your help,

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.


Group ghumidity
Number SZ_humidity "SZ [%.1f %%]" <humidity> (ghumidity)
Switch SZ_humidity_warning "[MAP(warnings.map):%s]" <humidity>


var humidity_Grenzwert = 70

rule "Warnung Luftfeuchtigkeit über Grenzwert"

	Time cron "0/5 * * * * ?"
	ghumidity.members.forEach [i|
	if (i.state > humidity_Grenzwert) {
		logInfo("Humidity Group", i.name + " beträgt " + i.state.toString + "%");
                sendCommand(i.name + "_warning" , ON)

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)?

Or do you have another solution in mind?

Thanks for your help!

What does it do? (openhab.log error message)
What does i.name + “_warning” look like? (openhab.log logInfo message)

Why not run your rule anytime one of the member Items changes, rather than by clockwork.
Then, you could only check the one that changed.

1 Like

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.

    Member of ghumidity changed
    if((triggeringItem.state as Number) > humidity_Grenzwert){
        sendCommand(triggeringItem.name+"_warning", "ON")

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.

1 Like

Thanks for your quick and 100%working help ! I will have a look at the Design Patterns.

I misunderstood the error message of the not existing quotes “ON”.