Using a function to run a code once until the input value changes

Hello!
I am trying to build a function in node red that runs a code and output the result only once until its input value changes. When the function is triggered, its will receive a global value and assign it to a variable, and then base on the nature of the value received, it will run a code once until the received value changes from its previous state. So far my code keeps on running and producing output even when the received value hasn't changed state. Here below is an image of what I’ve done so far

Get rid of the function, use a change node to add the global variable into the message. Pass the message through a filter node set to block unless changed.

Okay Steve, thank you. Let me give it a shot

It works. Thank you very much

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