Function filter 2

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;
}

Is this the same issue as your other post?

Duplicate of Function filter
closing this thread.