Search code examples
javascriptnode.jsfilternode-red

How to get a specific object and its parameters by ID in node-red?


msg.payload : Object
object
a_temperature: 20.8
a_humidity: 44
a_brightness: 0
a_lights: "off"
a_presence: "empty"
r_temperature: 34.67
r_humidity: 29.7
r_pressure: 1001.29
ID: "MC-307"
message: "Group_A1"
msg.payload : Object
object
r_temperature: 20
r_humidity: 80
r_pressure: 1000
a_temperature: 25.8
a_humidity: 39
a_brightness: 258
a_lights: "false"
a_presence: "false"
ID: "MC-302"
message: "Group_B2"

So I'm getting several messages as in form of these previously mentioned objects through MQTT-protocol. I want to get the whole object and its parameters and move it to an array which I have done. I need to get this object which "ID" is MC-302 and get every row in it and make it msg.payload, then wire the node to the array I have linked to the dashboard.

Is there any way to filter this same kind of objects by its ID?


Solution

  • You can use a switch node and filter by msg.payload.ID

    node-red node