Degree symbol in msg.payload

Hello.

I'm trying to add degree symbol (°C) in a msg.payload but something's wrong.

I use the function below:

msg.topic = "ECRAN-ENTREE/cmd";
msg.payload = Math.round(msg.payload.data_day.temperature_max[1])
msg.payload = msg.payload + "°C" ;
msg.payload = `NEXTION,home.t1.txt="${msg.payload}"`;
return msg;

The result is something like that: 15°C
Why there is an  before °C ?

Regards,

With this bit of code it works.

[{"id":"4199525f95a962f2","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload.data_day.temperature_max","v":"[1,2,3,4]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":2840,"y":1530,"wires":[["b0ef4d2772abb305"]]},{"id":"b0ef4d2772abb305","type":"function","z":"65c9b63cb09879a0","name":"","func":"msg.topic = \"ECRAN-ENTREE/cmd\";\nmsg.payload = Math.round(msg.payload.data_day.temperature_max[1])\nmsg.payload = msg.payload + \"°C\" ;\nmsg.payload = `NEXTION,home.t1.txt=\"${msg.payload}\"`;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":3000,"y":1530,"wires":[["a99e797e0140c213"]]},{"id":"a99e797e0140c213","type":"debug","z":"65c9b63cb09879a0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":3170,"y":1530,"wires":[]}]

But I don't know what your real incoming message looks like.

How about you post what the incoming message is too?

I would recommend a parseInt() to your msg.payload before you do + "°C" ... I use the + "°C" all the time and never seen that other symbol

Or Number( )

Thank you guys but the problem was not with nodered but with my display.

I will try to explain (i'm french and my english is ... poor): i'm using espeasy with nextion plugin to send data to a nextion screen. I send data to the plugin via mqtt.

For my degree symbol problem it was because the selected font was not good: with an utf-8 font it's OK.
The msg.payload was good.

Thank you for your help.
Have a merry christmas and an happy new year.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.