How to filter out "flapping" status

Can someone advise me on the following please?
I have an Bluetooth beacon and use geofency on my phone to call an http endpoint in nodered when the phone comes near to the beacon, and as well wenn it leaves the vicinity of the beacon (check-in / check-out).
Now while the phone is near the beacon, it occasionally loses the bluetooth connection for a second or so. So the signal is flapping in a short time frame which leads to frequent check-ins and outs.
Any idea how to filter this? Something like:
Getting an "out" after an "in" is delayed for 10s and only forwarded of no inverted signal is recieved within that timeframe or similar.
open for ideas.

thanks a lot!

Try using the filter/rbe node. It should be able to filter messages until a property value changes.

Thanks, I don't think that alone will solve it because the fluttering signal does represent changes.
However, I just found a node which seems to be designed for doing exactly what I want: node-red-contrib-debounce-leading-trailing. Will give it a try.

If you provide more info on incoming msg's, we could give example of how to use filter node

It basically is either msg.payload.dir === "in" or msg.payload.dir === "out"

But while being "in", it may happen that an "out" appears, followed by another "in" within 10s.
In that case, no change would happen.
If however no "in" follows the "out" within 10s, then the change happens.

thank you!

So use a trigger node in combination.
e.g.

[{"id":"9b66cd38.78f058","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload.dir","v":"in","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":720,"wires":[["9ca474fb.4174a"]]},{"id":"9ca474fb.4174a","type":"trigger","z":"c791cbc0.84f648","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":310,"y":740,"wires":[["396b845e.94655c"]]},{"id":"863c799c.8656b","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload.dir","v":"out","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":140,"y":780,"wires":[["9ca474fb.4174a"]]},{"id":"396b845e.94655c","type":"rbe","z":"c791cbc0.84f648","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload.dir","x":480,"y":740,"wires":[["407d1344.82c8ac"]]},{"id":"407d1344.82c8ac","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":740,"wires":[]}]

the trigger node will pass the latest msg received within 10 seconds

1 Like

Have a look at the delay node too.

that's pretty clever. Thank you!

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