How to seperate value from incoming msg.payload?

Hello,

I have now another flow where I want to make Dashboard through Gauge display, but same issue I am facing, -- I am not able to seperate out the payload value to send to gauge dispaly....below is simple flow through change node --but it is not working here ---Do I need to add here some function to sepearte out value?

below is the complete msg receved from Input node

You should make

set to: msg.payload
msg.payload.value

or directly on the gauge {{msg.payload.value}} without this change node

Regards

There’s also a great guide at https://nodered.org/docs/user-guide/messages
which shows you how to work out the route to any item in the msg object

This also not working

the value is not linked to gauge value

I assume when doing it like that you have wired the input node directly to the gauche whithout any change node right?

yes, it is without change node.

then let gauge as original with {{value }} and put in between a change node as follows

image

Or without the change node and on the value on the gauge put: {{payload.value}}

Gr8 It worked now by using change node above

Thanks

yw, if you don't use any change node and set on the gauge {{payload.value}} it will also work

Regards

Hi,
Can you please let me know the flow and the configs to achieve the OPC Value into a Gauge......

Thanks in Advance

BR
Satya

Sorry to open this old, old topic. I'm having trouble with this myself, and I've spent a couple days trying to figure it out.
Problem: I have a memory address in an I2C device that gives device status:

image

I can poll that address, receive an integer back, separate it into the corresponding bits. But I can't figure out how to output the 6 messages declaring the status (true or false, 1 or 0 doesn't matter) to make decisions... can someone help me?

[{"id":"7e15029f.3ab42c","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"8ae6db2.b5ec028","type":"i2c in","z":"7e15029f.3ab42c","name":"Lidar Status","busno":"1","address":"98","command":"1","count":"1","x":270,"y":140,"wires":[["56596c42.6e16f4","bfd11c29.08915"]]},{"id":"56596c42.6e16f4","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":140,"wires":[]},{"id":"bfd11c29.08915","type":"bitunloader","z":"7e15029f.3ab42c","name":"System Status","mode":"arrayBits","prop":"payload","padding":"8","x":460,"y":200,"wires":[["ac461ea.cc313e","32454ad1.b50786"]]},{"id":"ac461ea.cc313e","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":790,"y":200,"wires":[]},{"id":"d7b05339.a4322","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":260,"wires":[]},{"id":"f19a1ef1.d72a9","type":"inject","z":"7e15029f.3ab42c","name":"","props":[{"p":"payload"},{"p":"topic","v":"topic","vt":"flow"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":140,"wires":[["8ae6db2.b5ec028"]]},{"id":"32454ad1.b50786","type":"switch","z":"7e15029f.3ab42c","name":"Separate Statuses","property":"key","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"},{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"2","vt":"num"},{"t":"eq","v":"3","vt":"num"},{"t":"eq","v":"4","vt":"num"},{"t":"eq","v":"5","vt":"num"}],"checkall":"true","repair":true,"outputs":6,"x":550,"y":380,"wires":[["caabc82a.02f858"],["1e180185.c5efde"],["6aa8bd5d.9fa4c4"],["d292ce2.ed51f3"],["177c92c8.80ac1d"],["49917ca8.400dd4"]]},{"id":"1e180185.c5efde","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":320,"wires":[]},{"id":"6aa8bd5d.9fa4c4","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":380,"wires":[]},{"id":"177c92c8.80ac1d","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":500,"wires":[]},{"id":"d292ce2.ed51f3","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":440,"wires":[]},{"id":"49917ca8.400dd4","type":"debug","z":"7e15029f.3ab42c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":990,"y":560,"wires":[]},{"id":"caabc82a.02f858","type":"change","z":"7e15029f.3ab42c","name":"Set","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":260,"wires":[["d7b05339.a4322"]]}]

image

Before saying read this, read that, I've read and re-read it. I learn from seeing an example. I can understand and scale from there.

Please help me!

Thanking you in advance!

If you want to send each one of those values in the array out of a different output then you can use a Function node with the number of outputs set to 8, containing something like

// payload contains an array of values, build an array of messages containing those values
let msgs = msg.payload.map(myFunction)
return msgs

function myFunction(x) {
    return {payload: x}
}

That uses the Array map() function to convert the array values into an array of messages containing those values in msg.payload.

1 Like

Oh, my thank you SO much! I really appreciate your help with this!

It worked!

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