I have a flow that turns on lights when motion is detected and turns them off after 5 minutes. If within that time, there is motion again, the original delay is reset and the lights the delay is extended by 5 minutes. I was having trouble with the reset and restart of the delay (msg.delay would not restart the timer) and then I found the following solution:
The first change node sends a msg.reset to the delay node and the second change node sends a msg.delay (with the delay time in milliseconds) and also deletes the msg.reset attribute. In case it helps anyone, the flow is below:
[{"id":"1bd463ba.e98174","type":"group","z":"9eca1378.6f9de8","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["c93f2953.618f8","ef9fec05.c39388","cebe1f21.b302f8","619f8fb9.baa968","4fb293b1.8a9f1c","66ac105c.2f0258","3b765e9d.a3ee52","bb6a18d9.28d348"],"x":20.6666259765625,"y":4550,"w":777.9999694824219,"h":402},{"id":"c93f2953.618f8","type":"inject","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Original 30 sec trigger","payloadType":"str","x":195.33334350585938,"y":4786,"wires":[["ef9fec05.c39388","cebe1f21.b302f8"]]},{"id":"ef9fec05.c39388","type":"delay","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"30 Sec delay","pauseType":"delayv","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":451.3333435058594,"y":4788.66650390625,"wires":[["cebe1f21.b302f8"]]},{"id":"cebe1f21.b302f8","type":"debug","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Debug Message","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":572.3333435058594,"y":4911,"wires":[]},{"id":"619f8fb9.baa968","type":"change","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Reset Delay","rules":[{"t":"set","p":"reset","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":473.33331298828125,"y":4670,"wires":[["ef9fec05.c39388","4fb293b1.8a9f1c"]]},{"id":"4fb293b1.8a9f1c","type":"change","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Delay 45 Secs","rules":[{"t":"set","p":"delay","pt":"msg","to":"45000","tot":"num"},{"t":"delete","p":"reset","pt":"msg"},{"t":"set","p":"payload","pt":"msg","to":"New 45 sec trigger","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":692.6665954589844,"y":4671,"wires":[["ef9fec05.c39388"]]},{"id":"66ac105c.2f0258","type":"inject","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Delay 45 seconds","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Reset 45 sec trigger","payloadType":"str","x":267.3333435058594,"y":4672.000038146973,"wires":[["619f8fb9.baa968","3b765e9d.a3ee52"]]},{"id":"3b765e9d.a3ee52","type":"debug","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Delay Again","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":483.6666564941406,"y":4591,"wires":[]},{"id":"bb6a18d9.28d348","type":"comment","z":"9eca1378.6f9de8","g":"1bd463ba.e98174","name":"Test Delay Node","info":"","x":126.6666259765625,"y":4596.6669921875,"wires":[]}]