How to modify payload and display it in a text box

I have:
rpi-dht11 : msg : Object
{ topic: "rpi-dht11", _msgid: "d5bb2441c0209e4e", payload: "19.00", humidity: "59.00", isValid: true … }
and I want to multiply the "payload" by 1.8 +32 to convert it to F degrees and have it show up in my text box on the dashboard? How do I do that, I'm guessing with a function node.

In a change node
set msg. payload
to the value of J: $number($$.payload) * 1.8 - 32
and format in ui-text node in value format field
{{msg.payload | number : 1}} F the 1 means 1 decimal place

You could do it in a function node or a change node using jsonata. Here are two examples:

Using a change node:

[{"id":"efb89ae2bffa24b9","type":"inject","z":"ca32d36138412574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19.00","payloadType":"num","x":130,"y":160,"wires":[["26e15a95b49229d8"]]},{"id":"1d45869a320d7e8c","type":"debug","z":"ca32d36138412574","name":"debug 356","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":160,"wires":[]},{"id":"26e15a95b49229d8","type":"change","z":"ca32d36138412574","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"(payload * 1.8)+32","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":160,"wires":[["1d45869a320d7e8c"]]}]

using a function node:

[{"id":"d17982a23a425dc1","type":"function","z":"ca32d36138412574","name":"function 1","func":"msg.payload = (msg.payload*1.8) +32\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":220,"wires":[["71aa63bd90d53b81"]]},{"id":"71aa63bd90d53b81","type":"debug","z":"ca32d36138412574","name":"debug 357","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":220,"wires":[]},{"id":"bec56ca9baeffdbe","type":"inject","z":"ca32d36138412574","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"19.00","payloadType":"num","x":130,"y":220,"wires":[["d17982a23a425dc1"]]}]

The function worked great, thank you

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