Adding some Letters after converting with JS not possible

Hi i have the following Problem.

Input item:

Number MPC_Sensor1	"Number [JS(divide10.js):%s]"	<temperature>	{snmp="<[]"}

Sitemap item:

sitemap snmp label="snmp"
	Text item=MPC_Sensor1 label="Temperatur Garderobe"

Shows me:

“TempIcon” Temperatur Garderobe 22.1

But i want to have a 22.1°C

If i put

Input item:

Number MPC_Sensor1	"Number [JS(divide10.js):%s °C*]"	<temperature>	{snmp="<[]"}

it’s not showing up because the JS is getting executed and overwrites it.

If i only put:

Number MPC_Sensor1	"Number [%s °C*]"	<temperature>	{snmp="<[]"}

The sitemap shows me:

“TempIcon” Temperatur Garderobe 221 °C

So i can either devide by ten or i can add the “°C” at the end.

With the modbus Binding i do not have this problem because there i can use the JS even in the binding like:

Number Heliotherm1 "Number [%.1f°C]"	<temperature>	{modbus="<[slave2:1:transformation=JS(divide10.js)]"}

Does anyone have a idea ?


Try adding the °C in the divide.js transform file

// Wrap everything in a function
(function(i) {
    return parseFloat(i) / 10+"°C";
// input variable contains data passed by openhab