Hello everybody i know this Theme About Adding a delay in a function but im new and i Need some help.
In my Function "Katze kommt/geht " i Need a delay of 5Sec after the return of the msg1 and msg2. So only the first Sensor who was activatet will return the msg and after the 5Seconds ist possible that the second Sensor activates = return msg2 = 5sec delay.
i hope someone can help me thank you and sry for the bad english
[{"id":"dca71496.fc34d8","type":"tab","label":"Corbaz","disabled":false,"info":""},{"id":"9868ba65.a0e578","type":"trigger","z":"dca71496.fc34d8","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"Set Trigger","x":450.14849853515625,"y":125.64457511901855,"wires":[["327a180e.7f0d08"]]},{"id":"3ff08023.f2ead","type":"trigger","z":"dca71496.fc34d8","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","name":"Set Trigger","x":337.01953887939453,"y":331.0039482116699,"wires":[["327a180e.7f0d08"]]},{"id":"f55e4cf4.d396c","type":"ui_text","z":"dca71496.fc34d8","group":"b547b27f.d5b82","order":0,"width":0,"height":0,"name":"Sensor auslesen","label":"Katzen im Haus","format":"{{msg.payload}}","layout":"row-spread","x":764.1487083435059,"y":238.32819366455078,"wires":},{"id":"9cefb4d8.1a3638","type":"rpi-srf","z":"dca71496.fc34d8","name":"Sensor Aussen","topic":"Aussen","pulse":"1","pins":"11,12","x":107.01953125,"y":34.003926277160645,"wires":[["ab8d24f2.2d07d8"]]},{"id":"1b27ac8c.f67de3","type":"rpi-srf","z":"dca71496.fc34d8","name":"Sensor Innen","topic":"Aussen","pulse":"1","pins":"3,5","x":79.01953125,"y":450.0039176940918,"wires":[["46755109.e33ea"]]},{"id":"328128e0.236cc8","type":"function","z":"dca71496.fc34d8","name":"set Globale variable Sensoraussen","func":"global.set("Sensoraussen",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":405.01953125,"y":44.003915786743164,"wires":[["9868ba65.a0e578"]]},{"id":"f72d2d12.c3529","type":"function","z":"dca71496.fc34d8","name":"set Globale variable Sensoraussen","func":"global.set("Sensorinnen",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"x":271.01953125,"y":388.00392150878906,"wires":[["3ff08023.f2ead"]]},{"id":"ab8d24f2.2d07d8","type":"switch","z":"dca71496.fc34d8","name":"<=15","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"10","v2t":"num"}],"checkall":"true","repair":false,"outputs":1,"x":99.14063262939453,"y":102.0703182220459,"wires":[["328128e0.236cc8"]]},{"id":"46755109.e33ea","type":"switch","z":"dca71496.fc34d8","name":"<=15","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"0","vt":"num","v2":"10","v2t":"num"}],"checkall":"true","repair":false,"outputs":1,"x":127.01953125,"y":340.00390625,"wires":[["f72d2d12.c3529"]]},{"id":"bf644e00.1cfcb","type":"debug","z":"dca71496.fc34d8","name":"katze kommt","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":679.14453125,"y":135.453125,"wires":},{"id":"327a180e.7f0d08","type":"function","z":"dca71496.fc34d8","name":"Katze kommt/geht ","func":"var Sensoraussen1 = global.get("Sensoraussen");\nmsg.payload = Sensoraussen1;\nvar Sensorinnen1 = global.get("Sensorinnen");\nmsg.payload = Sensorinnen1;\nvar msg1 = {payload: "Katze kommt"};\nvar msg2 = {payload: "Katze geht"};\nvar myVar;\n\nif (Sensoraussen1 > Sensorinnen1){\n \n return (msg1);\n}\nelse if (Sensorinnen1 > Sensoraussen1){\n \n return (msg2);\n }","outputs":2,"noerr":0,"x":521.0196228027344,"y":230.00392627716064,"wires":[["f55e4cf4.d396c","bf644e00.1cfcb"],["a5621543.4eecd8"]]},{"id":"a5621543.4eecd8","type":"debug","z":"dca71496.fc34d8","name":"katze geht","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":722.01953125,"y":299.00390625,"wires":},{"id":"b625bc1c.7fed7","type":"function","z":"dca71496.fc34d8","name":"Katze kommt/geht ","func":"var Sensoraussen1 = global.get("Sensoraussen");\nmsg.payload = Sensoraussen1;\nvar Sensorinnen1 = global.get("Sensorinnen");\nmsg.payload = Sensorinnen1;\nvar msg1 = {payload: "Katze kommt"};\nvar msg2 = {payload: "Katze geht"};\n\nif (Sensoraussen1 > Sensorinnen1) {\n while (Sensoraussen1 > Sensorinnen1)\n return [msg1,null];\n}\nelse if (Sensorinnen1 > Sensoraussen1){\n while (Sensorinnen1 > Sensoraussen1)\n return [null,msg2];\n}","outputs":2,"noerr":0,"x":806.01953125,"y":536.00390625,"wires":[,]},{"id":"b547b27f.d5b82","type":"ui_group","z":"","name":"Sensor auslesen","tab":"e00e648.58db998","disp":true,"width":"6","collapse":false},{"id":"e00e648.58db998","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]