At the root of flow based programming is the message.
It is a collection of one or more related bits of data.
For example an external sensor sends a message containing a timestamp, temperature, humidity and air pressure values.
This message travels along the wires between the nodes in the flow.
They might use it to update a database, to add new points on a chart, to trigger a warning email, and so on.
Ideally, everything needed by the processing is a part of the message.
Of course sometimes you need to compare this message with the previous one.
One way might be to introduce a function node like this:
msg.payload.previoustemp = context.get('previoustemp') || 0 // the default is 0
context.set('previoustemp', msg.payload.temperature)
return msg
Note that this context variable has no existence outside this single function node.
There is no way that it can fail to tack the previous temperature (or zero) onto the payload.
If another flow uses an identically named variable it will not interfere with this node.
Consider this little flow
If writing to the database takes a little time and a new message arrives, it doesn't matter. The previous value is safely attached to the payload, all the nodes are using the same data .
Now consider your way, comparing the current value with a global context variable.
If a new message arrives, there is scope for the context variable to be reset before you have finished using it.
Worse, you forgot an unrelated flow from last year which also uses global.previoustemp. Now messages in that flow can "magically" interfere with this one, and vice versa.
I have used a function node in this example, hopefully it's easy to understand. But it can be done, probably more efficiently, without functions.
Finally, my first reply above suggests using a filter node like this

The filter automatically compares this message with the previous one.
The message will only be passed to the LED if the filtered property (msg.payload.temperature) changes from the previous value.
I think this is all you need to prevent your machines receiving duplicates.