[SOLVED] Manipulate String state

Hey there,

I got the following problem. I visualize a threshold of a heater. The problem is that the value isn`t shown in the way I want. The value that I receive from my home automation system is “1270 °C” and that’s how it is saved in its system. In my sitemap I want it to be shown as “27 °C” or “27.0 °C”. Is there a way to achieve this? Maybe by using rule-engine?

Here is my item-data

String MeinZuhause_Temperaturregler_Item_Anzeige "Item [%s °C]" {lcn="[myhome:THRESHOLD_VALUE.0.0.1.1]"}
Switch MeinZuhause_Temperaturregler_Item "Item" {lcn="[ON:myhome:KEYS.0.0.A1.HIT], [OFF:myhome:KEYS.0.0.A1.HIT]"}

sitemap-data

sitemap default label="Mein Zuhause"
{
	//Temperaturregelung
	Frame label="Temperaturregelung"
	{
		//Temperaturregelung
		Switch item=MeinZuhause_Temperaturregler_Item label="Item Büro-Keller" icon="temperature" mappings=[ON="↑", OFF="↓"]
		Text item=MeinZuhause_Temperaturregler_Item_Anzeige label="Solltemperatur Büro-Keller" icon="temperature"
	}
}

Does it always shows temperature on four digit?

Uhm… Is “1270 °C” really “27 °C?” or “12.80 °C”?
If yes this would be the solution I think

[%.1f °C] This will results in something like this

ps. I know Humidity is not measured in °C, just for displaying purposes

No its not, if i change the threshold to -1 °C it is shown as 990 °C

“1270°C” is really “27 °C”. I tried your solution but the result was, that it only adds one digit :confused:

Did you try making the item a number?

Number MeinZuhause_Temperaturregler_Item_Anzeige "Item [%.1f °C]" {lcn="[myhome:THRESHOLD_VALUE.0.0.1.1]"}

Yep already tried it but forgot to mention it. In the figure above it is already defined as a number.

I don’t really understand the binding docs so I would use a proxy item:

Number Real_MeinZuhause_Temperaturregler "Solltemperatur Büro-Keller [%.1f °C]" <temperature>

And then a rule:

Rule "Process temp"
when
    Item MeinZuhause_Temperaturregler_Item_Anzeige changed
then
    var temp = MeinZuhause_Temperaturregler_Item_Anzeige.state as Number
    temp = (temp - 1000) / 10
    Real_MeinZuhause_Temperaturregler.postUpdate(temp)
end

And your sitemap:

sitemap default label="Mein Zuhause"
{
	//Temperaturregelung
	Frame label="Temperaturregelung"
	{
		//Temperaturregelung
		Switch item=MeinZuhause_Temperaturregler_Item label="Item Büro-Keller" icon="temperature" mappings=[ON="↑", OFF="↓"]
		Text item=Real_MeinZuhause_Temperaturregler
	}
}
1 Like

That´s it. Tried it out and it worked.

Thank you all for your help and for the time u invested to solve this problem.

It is very nice to have such a helpful community, keep going!