Only forward a message after two consequative messages with same payload

I'm parsing something from a noisy source (literal, ascii noise over the line), and I want to filter out "wrong" messages by only sending stuff along after I've seen the same value twice in a row. Since it's a slow moving sensor, this is quite an okay noise reduction.

So how could I build this accumulating behavior?

You could pass the message through a switch node set to equals previous payload.
e.g.

[{"id":"00e5cf23448a2121","type":"switch","z":"452103ea51141731","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"","vt":"prev"}],"checkall":"true","repair":false,"outputs":1,"x":250,"y":860,"wires":[["8b685ae0571bd80d"]]},{"id":"e79d2b295950adc1","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"a","payloadType":"str","x":110,"y":840,"wires":[["00e5cf23448a2121"]]},{"id":"ec76edf4ddfc8ce7","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"b","payloadType":"str","x":90,"y":900,"wires":[["00e5cf23448a2121"]]},{"id":"8b685ae0571bd80d","type":"debug","z":"452103ea51141731","name":"debug 98","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":880,"wires":[]}]

@E1cid beat me to the suggestion I was leaning toward, though for similar situations you may also find value in node-red-contrib-debounce (node) - Node-RED

aah, interesting.

I solved it using 2 smooth filters with a window of 2, a min & max, and then joining on the output and checking if they are the same.

But I like this switch much better, didn't know they had access to the previous value :+1:

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