NodeRED - Timer at idle being read as active - SOLVED

TLDR: Make sure that a flow checking timer state has the “ignore input override” checkbox set.

I have a timer.finished event which makes an action depending on another timer being idle.
In the flow shown there are two timers and they both check if the other one is idle before action.

If the other timer state is checked immediately after the timer.finished event then it always reports to be active. If a delay is included before checking the other timer state then it reports correct.

What am I doing wrong?

My best guess is that the timer is still active until it goes idle, and that happens after the event.
Which makes sense when I think about it, the event happens and something reacts to change the state.
You can probably delay 200 ms and it will be enough.

Is it important that you read the state at the same time as the timer finished?

Sorry, I didn’t make myself clear enough.

When timer 1 times out, it checks that timer 2 is idle.
Timer 2 was not running or had ever run since the flow started.
Timer 2 still reports as active.

This same sequence works perfectly in an automation.

Changing the test logic to be “not active” instead of “equals idle” makes no difference.
Triggering the timer check manually results in the correct response. That made me think of putting the delay in.

This is unexpected and maybe broken behavior. Other users would have the same problem and have to discover the delay hack themselves.

Unless I am doing something wrong.

Could be something in the message is causing the problem. If you don’t have input override checked in the current state node, check that box.

The message when it runs through the delay node may change. Put a debug after the switch and the delay. Select complete message object and compare the 2 messages.

1 Like

Good idea but it didn’t show a difference across the delay.

This checks the timer state before and after delay. It shows active when first triggered and idle after.

The debug outputs from immediate and delayed show the original timer information, not the checked timer state. Not sure how to fix that.

This fixes it.
Thanks for your help.

1 Like