Hey guys,
I´m coming from typescript and I can´t figure out how to do it in Xtend:
rule “NotifyPowerChanges”
when
Item PowerA_ErdgeschossKuecheKuehlschrank changed or Item PowerA_KellerTechnikraumKuehlschrank changed or Item PowerA_ErdgeschossWaschraumGefriertruhe changed //Time cron "0 0/1 * * * ?"
then
var mText = "" val addText = [SwitchItem item | mText = mText.concat("\n"+item.getName()+": "+item.state.toString()+" (lastupdate: "+item.lastUpdate?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+")") ] addText(PowerA_ErdgeschossKuecheKuehlschrank) var item = PowerA_ErdgeschossKuecheKuehlschrank mText = mText.concat("\n"+item.getName()+": "+item.state.toString()+" (lastupdate: "+item.lastUpdate?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+")") item = PowerA_ErdgeschossWaschraumGefriertruhe mText = mText.concat("\n"+item.getName()+": "+item.state.toString()+" (lastupdate: "+item.lastUpdate?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+")") item = PowerA_KellerTechnikraumKuehlschrank mText = mText.concat("\n"+item.getName()+": "+item.state.toString()+" (lastupdate: "+item.lastUpdate?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+")")
val mailActions = getActions(“mail”,“mail:smtp:bitpoint”)
mailActions.sendMail(“my@address.de”, “OH changes in cooling”, mText)
I want to put the repeating line
mText = mText.concat("\n"+item.getName()+": “+item.state.toString()+” (lastupdate: “+item.lastUpdate?.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)+”)")
in the anonymous function “addText” and call it for all Items, but It´s not working
Can someone point me in the right direction ?
Thanks