Okay, spent some time on this.
You have a group of Items Termostat_xxx_Ist, each of which has a counterpart Termostat_xxx_Soll
You want to produce some text for this set like
" xxx ist-label : 12.00 °C | xxx soll-label : 18.00 °C
yyy ist-label : 15.00 °C | yyy soll-label : 16.00 °C"
Let’s not mess with placeholder text, just do it directly using method from here
Design Pattern: Associated Items.
// make a stringy object val that we can still append to
val StringBuilder myMessage = new StringBuilder
// iterate through "Ist" Items
allTermostatIst.members.forEach[ist |
// add label text
myMessage.append(ist.label + " : ")
// add state
myMessage.append(ist.state.toString + " | ")
// work out partner Item name
val sollName = ist.name.replace("_Ist", "_Soll")
// get partner Item from its group
val soll = allTermostatSoll.members.findFirst[ a | a.name == sollName]
if (soll === null) {
// surprise
myMessage.append("Missing Soll Item " + sollname)
} else {
// now do soll label and value
myMessage.append(soll.label + " : ")
myMessage.append(soll.state.toString + "/n")
}
]
// all done
telegramAction.sendTelegram(myMessage)