# How to filter out "flapping" status

**URL:** <https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087>\
**Category:** General\
**Created:** [4 January 2022 14:39 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087 "2022-01-04T14:39:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaeti01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaeti01/32/15005_2.png) [@jaeti01](https://discourse.nodered.org/u/jaeti01)\
**Post date:** [4 January 2022 14:39 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/1 "2022-01-04T14:39:28Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 January 2022 14:58 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/2 "2022-01-04T14:58:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jaeti01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaeti01/32/15005_2.png) [@jaeti01](https://discourse.nodered.org/u/jaeti01)\
**Post date:** [4 January 2022 15:07 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/3 "2022-01-04T15:07:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 January 2022 15:10 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/4 "2022-01-04T15:10:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jaeti01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaeti01/32/15005_2.png) [@jaeti01](https://discourse.nodered.org/u/jaeti01)\
**Post date:** [4 January 2022 15:31 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/5 "2022-01-04T15:31:50Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [4 January 2022 15:38 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/6 "2022-01-04T15:38:54Z")

</div>

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

```auto
[{"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

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [4 January 2022 16:49 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/7 "2022-01-04T16:49:47Z")

</div>

Have a look at the delay node too.

---

<div class="post-metadata">

**Author:** ![jaeti01](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaeti01/32/15005_2.png) [@jaeti01](https://discourse.nodered.org/u/jaeti01)\
**Post date:** [4 January 2022 20:12 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/8 "2022-01-04T20:12:20Z")

</div>

that's pretty clever. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [18 January 2022 20:12 UTC](https://discourse.nodered.org/t/how-to-filter-out-flapping-status/56087/9 "2022-01-18T20:12:29Z")

</div>

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