Get value based on object.id

Hi.
I have an object with an array of objects. I want to use a function node to get one spesific value based on the object id.
So if I only want temp from a speseific device/object
if msg.payload.object.id == "2920009404" then msg.payload = msg.object.temp?

Have a look at the array filter function.

Thanks for the tip. Solved it with this code.

msg.payload = msg.payload.devices.filter(el => el.id === "V004b11e12")
msg.payload = msg.payload[0].data.controlSignal

return msg;
1 Like

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