ON and OFF delay timer

Hey folks, I am building an alarm system logic with dashboard ui, I am looking for ON delay function which I can delay the alarm set for 1 minutes and no delay when alarm system been switched off manually on dashboard.

Anyone got any clue on where to find such node or function?

You could use a Switch node to send On and Off down separate paths then put a delay node in the On path. Then join the paths together again if appropriate.
You might need to think about the requirement a bit more though. Watch out for things like switching it on then immediately off again and make sure your logic copes with that. So I suggest first making sure you know exactly what you want the system to do. Then work out how to implement it.

This would be a good instance in which to use a DSM (State Machine) - but if that is not the way you want to go - then just use a global context variable to hold the state

AlarmState = on/off

When you arm the panel - set the variable to On, when you disarm set the variable to off check in your flow for this with a switch node - if Variable is On - then delay 1 minute and proceed, if Off then go to the next node immediately

Craig

Thanks for your hint Colin, takes me a while to resolve the issue.
Instead of using a DELAY node after the SWITCH node, I end up using a TRIGGER node (send 0, wait for x amount of time, then send 1, reset the trigger if msg.payload=0). This solves the issue that occurs when 0 is send immediately after 1.

1 Like