Node-RED combining value and unit in one object

Find and share HowTos to various installations / configurations!
Search

Post Reply
2 posts • Page 1 of 1
aleksandar.postolov
Posts: 19
Joined: Thu Sep 05, 2013 3:51 pm

Node-RED combining value and unit in one object

Post by aleksandar.postolov »

Hi everyone

I am playing with node-red in 3.17 and it's pretty cool so far. I am struggeling though, with combining the differend payloads from dpGet and dpGetUnit.

What I am trying to do is displaying a chart with the given unit from the datapoint. I do get the value and the unit from the datapoint, but I can't combine/join them, to display in the same chart.

Anyone an idea or expirience with node-red?

Best regards
Aleks

c.fraenzer
Posts: 8
Joined: Wed Jun 12, 2019 4:19 pm

Re: Node-RED combining value and unit in one object

Post by c.fraenzer »

Use a function block and pass both objects to it.

Then access the objects in the function as following

Code: Select all


var msg1 = {payload: msg.payload[1]};
var msg2 = {payload: msg.payload[2]};

var ret = msg1 + " " + msg2;

return ret;

if you look at the message object in the Debug window you can choose the right path to the object and paste it in the brakets.

If you have more questions regarding node Red just say so


Greetings

Post Reply
2 posts • Page 1 of 1