Trigger a flow if state changes to false and stays at false for over a minute

Sorry folks if this is already answered, but I'm searching and experimenting now for hours without any progress.

Problem:

I have a node that fires true or false, depending if a server connection is alive or dead.
As long as true messages are coming, all is ok, nothing to do.
But if false messages are coming for more than 1 minute (without any true message in this time), I need to start a flow to take some action.

I experimented with Delay and Trigger Node, but so far I have no glue how to handle this.

In theory it is easy:

  • if a false message is coming, start a timer with one minute and ignore all following false messages
  • if a true message is coming, reset the timer (and ignore all following true messages or again reset the timer, does not matter)
  • if timer fires (1 minute is over and no true message arrived in this time), fire the action flow and reset timer

Thanks, Max

Do you mean this

[{"id":"da2756de.d5664","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":3160,"wires":[]},{"id":"63503f14.9acb28","type":"trigger","z":"bf9e1e33.030598","name":"","op1":"","op2":"false for 1 min","op1type":"nul","op2type":"str","duration":"1","extend":false,"overrideDelay":false,"units":"min","reset":"true","bytopic":"all","topic":"topic","outputs":1,"x":320,"y":3200,"wires":[["da2756de.d5664"]]},{"id":"591b2162.21b8f8","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":131,"y":3195,"wires":[["63503f14.9acb28"]]},{"id":"67c6f334.9f7c84","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":121,"y":3235,"wires":[["63503f14.9acb28"]]}]
1 Like

one note about @E1cid's flow. after a deploy you have to inject at least once to set the trigger node or the node won't fire. After a deploy, if no server messages come in it will never fire the trigger node. You have to have at least one message. I solve this by using an inject node set to fire once at power on which then sets the trigger. This may be an edge situation but be aware it could happen.

2 Likes

Wow, it is really easy if you know how :upside_down_face:
Thank you very much!

Thank you for the hint on initialisation, works perfect now

2 Likes

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