# Function filter 2

**URL:** <https://discourse.nodered.org/t/function-filter-2/32873>\
**Category:** Industrial\
**Created:** [14 September 2020 12:24 UTC](https://discourse.nodered.org/t/function-filter-2/32873 "2020-09-14T12:24:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pm.integrator](https://avatars.discourse-cdn.com/v4/letter/p/e19b73/32.png) [@pm.integrator](https://discourse.nodered.org/u/pm.integrator)\
**Post date:** [14 September 2020 12:24 UTC](https://discourse.nodered.org/t/function-filter-2/32873/1 "2020-09-14T12:24:53Z")

</div>

Hello everyone,  
I'm starting to work with node-red in the field of building automation, I would have a need that should be solved with a function node, basically I have a home automation system (system A) with modbus ip connection, from there come the commands that must then be sent to a listening tcpip server (system B). The formatting I receive from the modbus is the same that I should then send to system B, it is a single holding register which varies its value.  
Considering that I have to poll (100 ms) to have the calls updated from system A, if there are no variations to system B the same data is sent, but I should apply a filter or something that only passes the variations coming from system A.  
Below is the function I am using with the problem that if there are no changes, it sends the same data cyclically.  
Basically what I should get is that the data (modbus register) that passes through the function node must pass only on variation and avoid the repeated sending of the same value.  
Thank you very much.

Node function:

var buff = global.get;  
if (msg.payload! = buff)  
{  
buff = {payload: msg.payload};  
return buff;  
}  
else  
{  
return null;  
}

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 September 2020 12:27 UTC](https://discourse.nodered.org/t/function-filter-2/32873/2 "2020-09-14T12:27:40Z")

</div>

Is this the same issue as your other post?

> [@Function filter](https://discourse.nodered.org/t/function-filter/32869/2):
>
> Sounds like you need to use the RBE node. It only allows a msg to pass if it has changed.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 September 2020 12:28 UTC](https://discourse.nodered.org/t/function-filter-2/32873/3 "2020-09-14T12:28:18Z")

</div>

Duplicate of [Function filter](https://discourse.nodered.org/t/function-filter/32869)  
closing this thread.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [14 September 2020 12:28 UTC](https://discourse.nodered.org/t/function-filter-2/32873/4 "2020-09-14T12:28:22Z")

</div>


