Current State Node - State for

Hi,

I’m trying to understand how the current state node works. In particular the If state of the node.

Let’s make a comparison with the Events: State node
I have created a test input boolean to test the nodes, just for comparison.

As you can see in below image, the Events state node is configured to pass an output when the boolean has been ‘off’ for 5 seconds:

And in this image you can see that the expected output is generated.
I get a log when the boolean turns off, and then 5 seconds later when it has been off for 5 seconds.

However, it seems to work differently in the Current State Node.
When configured like this, (without the ‘for’ filled), it correctly outputs the state to the correct output. OFF goes through the first output, and ON in the second one.

But as soon as I set a time in the FOR field, in this example 5 seconds, it passes both ON and OFF in the same output. So even though the state of the entity is OFF, it outputs to on.

Is there someone that can explain this behaviour?

A Current State time check is a look back “has been off for 5 secs”, so since that is false since you just changed the state ahead of doing the check it sends it to the 2nd output (false is the trigger not “on” that is causing it to go to the 2nd output). I would bet if you grabbed the message object from the 2nd output it would be “off” in your second pass.

Thanks for explaining that.
Indeed, if I delay the message coming in to the node longer than what the timeout is set to. It passes the message in the “off” output

Is there any node that you know of that can actually achieve that?
E.g. when a message arrives, wait until an entity has had a specific state for a given amount of time?

Yes look where the HA nodes are.

image