Thankyou. Didn't thought it to be this simple
there is one more thing with this flow. I also need to remove the duplicate values. I was going through solutions given below. How can I make them use in this flow.
Your function is not returning the msg. so no option set. Then your change node overwrites msg.option with msg.payload.
But to only pass on changed msg.options compare the array lengths. e.g.
[{"id":"f454e332.520a5","type":"inject","z":"63af3844.ce5a8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"test1/Node1/2/Data","payload":"{\"ID\":\"13dfsl48\",\"TimeStamp\":0,\"SensorNamwe\":\"Sensor_3\",\"SensorRaw\":-332,\"Senā¦
I would take the lazy approach and use a function node.
var prev = null;
msg.payload = msg.payload.filter((item) => {
var keep = (item.x !== prev);
prev = item.x;
return keep;
});
return msg;
This assumes you only want to dedupe on 'x', and they are all in sequence. You would have to modify it a bit if that's not the case.