Update String Item with LineFeed/CarrigeReturn

I use this code to update an item:

var String msg = ""
			msg="Stato Termostato Richiesto:"+
			"\r\nStato Termostato="+TERMOSTATO_STATUS.state+
			"\r\nTermostato OpenHab="+TERMOSTATO_OPENHAB_CNT.state+
			"\r\nTermostato Calendario="+TERMOSTATO_CAL.state+
			"\r\nTermostato Manuale="+TERMOSTATO_MAN.state+
			"\r\nTemperatura Impostata="+TERMOSTATO_T_SET_POINT.state.toString+//.substring(0,5)+
			"\r\nPotenza Impostata(Servo)="+TERMOSTATO_S_SET_POINT.state+
			"\r\nTemperatura Ambiente="+INGRESSO_CURRENT_TEMP.state.toString+//.substring(0,5)+
			"\r\nPotenza Effettiva(Servo)="+CALDAIA_SERVOPOS_SOULISS.state+
			"\r\nControllo Caldaia="+CALDAIA_CONTROLLO.state+
			"\r\nControllo Assenza="+TERMOSTATO_ASSENZA.state+
			"\r\nEscludi Assenza="+TERMOSTATO_ESCLUDI_ASSENZA.state

			NOTIFICATION_PUSHOVER.postUpdate("openhab|0|Stato Termostato|"+msg)

The item loose the carriage return. When the item NOTIFICATION_PUSHOVER will be updated a new rule with fired to send notification with Pushover, and I need full text, but in this case only the 1st line of the string msg will be passed.

any suggestion?


Try without the \r

Hi @rlkoshak
I tried before opening this thread.
I solved with a trick.
In 1st rule i transformed the \r\n into a string using a double back slash,


Then in second rule fired on Item update, I string replace


with \r\n
It works very well


You can’t use the \r\n in the String to begin with? You have to do a find a replace?

Hi @rlkoshak
if I use \r\n in the string passing from an Item from a rule to another, \r\n are not onored in second rule.
Using replace, \r\n are honored in second string.
You can try, from a rule setup an item with some text including \r\n. Then from anoter rule, retrieve the item.
\r\n are gone.


1 Like