Checking status change after a given delay


Need a bit of help here.

I'm checking a GPIO change of state. When a change of state happens, I need to wait for a predetermined amount of time, check again and only take action if the status change is the same after that specific period of time has elapsed.

I kind of know that setTimeDelay needs to be used, but couldn't figure out how to use it to achieve my objective - I'm being confused by the callback arrangements and how they work.

Thanks in advance.

If you are doing it in a function node then it is setTimeout that you need to use
However I think node-red-contrib-debounce will do exactly what you want without resorting to a function node.

Hi Colin,

Thanks for your reply.

It's actually not to debounce a switch - I'm doing this with a GPIO node with a configurable debounce period.

This is to trigger a provisioning routing after a key has been pressed more than a given amount of seconds.

Thanks again ..


What is the difference? The debounce node will do what you asked.
If it is the fact that it debounces the Off signal too then you can add a Switch node after the debounce so only On signals get through.