Help with trigger/condition

I am trying to convert one of my automation to node red but am having some trouble.

I want to send a notification if the state of a sensor changes from false to true and stays that way for 3 minutes.

I’m not sure how incorporate the 3 minute wait into node red. I think I have the rest figured out. The trigger in the home assistant automation is as follows

Trigger type: State
Entity:sensor.washer_pwrdn
from: false
to: true
for: 00:03:00

Could I just use a simple delay node? Would this delay be reset when the state changes from false to true and back to false?

1 Like

You can use the delay node.

To stop the flow, use the “Halt if state” is false.

1 Like

I was trying to accomplish the same thing. This looks like a simple solution, I’ll have to give it a try.

Works great! Very simple solution.

No, it won’t, areks solution only check if the state is true 3 minutes after every state change to true, without noticing how many times it changed in between. A better solution for your problem would be to use the trigger node, configured like this it will only emit states stable for at least 3 minutes and discard every state which is not. Then a simple switch node to check if the state (which have been stable for 3 minutes) is actually true.

Note that you have to check the “Output only on state change” checkbox on the events:state node.

[{“id”:“845a6ca0.379698”,“type”:“trigger”,“z”:“eeb7694d.de6c18”,“op1”:“”,“op2”:“”,“op1type”:“nul”,“op2type”:“payl”,“duration”:“3”,“extend”:true,“units”:“min”,“reset”:“”,“bytopic”:“all”,“name”:“”,“x”:517,“y”:1423,“wires”:[[“99b37f7.c8cfd”]]},{“id”:“8c3c94c8.90138”,“type”:“server-state-changed”,“z”:“eeb7694d.de6c18”,“name”:“”,“server”:“b3647e80.a78bd”,“entityidfilter”:“input_boolean.notalone”,“entityidfiltertype”:“exact”,“outputinitially”:false,“state_type”:“habool”,“haltifstate”:“”,“halt_if_type”:“str”,“halt_if_compare”:“is”,“outputs”:1,“output_only_on_state_change”:true,“x”:276,“y”:1423,“wires”:[[“845a6ca0.379698”]]},{“id”:“99b37f7.c8cfd”,“type”:“switch”,“z”:“eeb7694d.de6c18”,“name”:“true?”,“property”:“payload”,“propertyType”:“msg”,“rules”:[{“t”:“true”}],“checkall”:“true”,“repair”:false,“outputs”:1,“x”:656.5,“y”:1423,“wires”:[]},{“id”:“b3647e80.a78bd”,“type”:“server”,“z”:“”,“name”:“HASS”,“legacy”:false,“hassio”:false,“rejectUnauthorizedCerts”:true,“ha_boolean”:“y|yes|true|on|home|open”}]

3 Likes

Oh, I totally missed that part when I read the message. Your solution is indeed the correct one for this problem!

Thank you both for your responses. I have updated the flow and it works as intended.

1 Like