I use either this:
Is it on? > fow how long? > if it’s been on for more than 10’’, then do, otherwise set a delay as long as the remaining time in a trigger node.
[{"id":"f2260be1.473cb8","type":"api-current-state","z":"d4c74d4.b950eb","name":"binary on?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary","state_type":"str","blockInputOverrides":true,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":1290,"y":1360,"wires":[["bafa0e06.5d5e6"],[]]},{"id":"bafa0e06.5d5e6","type":"switch","z":"d4c74d4.b950eb","name":">= 10''","property":"data.timeSinceChangedMs","propertyType":"msg","rules":[{"t":"gte","v":"10000","vt":"num"},{"t":"else"}],"checkall":"false","repair":false,"outputs":2,"x":1450,"y":1360,"wires":[["a552b218.c68"],["40e2e746.da1e08"]]},{"id":"25f094db.337a5c","type":"trigger","z":"d4c74d4.b950eb","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"250","extend":true,"overrideDelay":true,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1435,"y":1420,"wires":[["f2260be1.473cb8"]],"l":false},{"id":"a552b218.c68","type":"debug","z":"d4c74d4.b950eb","name":"Do","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1610,"y":1340,"wires":[]},{"id":"40e2e746.da1e08","type":"change","z":"d4c74d4.b950eb","name":"Set delay","rules":[{"t":"set","p":"delay","pt":"msg","to":"10000 - $number(data.timeSinceChangedMs)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1320,"y":1420,"wires":[["25f094db.337a5c"]]},{"id":"502e9d10.37d554","type":"inject","z":"d4c74d4.b950eb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1120,"y":1360,"wires":[["f2260be1.473cb8"]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
I also use this one:
Using the opposite logic in a wait until node. If it goes off, do nothing. If it doesn’t go off in 10’’, use the timeout output to Do.
[{"id":"206f7975.7118c6","type":"ha-wait-until","z":"d4c74d4.b950eb","name":"","server":"9405c3fe.d0a6c","version":0,"outputs":2,"entityId":"binary","entityIdFilterType":"exact","property":"state","comparator":"is","value":"off","valueType":"str","timeout":"10","timeoutType":"num","timeoutUnits":"seconds","entityLocation":"","entityLocationType":"none","checkCurrentState":true,"blockInputOverrides":true,"x":1350,"y":1600,"wires":[[],["db6d7bae.6ae518"]]},{"id":"3fadcae9.103f96","type":"inject","z":"d4c74d4.b950eb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1170,"y":1600,"wires":[["206f7975.7118c6"]]},{"id":"db6d7bae.6ae518","type":"debug","z":"d4c74d4.b950eb","name":"Do","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1510,"y":1620,"wires":[]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
Depending on the scenario one works better than the other.