A starter needs some help for a simple que (flow?)

Good evening.
Yesterday I started HA and programming in node-RED.
I did succeed with one que.

Now my second que I can not figure out get it working.
I like a light switched on bij PIR active and switch off the light after 3 minutes, except in the time between the 3 minutes and de PIR is activated again the timer starts again.

This is my best result except the light is not switching out again, because if the wait until timer is finished, the PIR is not sending a signal anymore to go true.
I tried also the tile delay. This works, but will not be reset timer after a new PIR state

I also like to include in the que, if instead of the PIR, the normal switch is used for switching on light, it also will be automatic switched of after 3 minutes
For that this que did work the best, but again timer is not reset after a new PIR state

Please advise.

Install this node:

When the node gets a message (motion), it will pass it through. Use that message to turn on the light. Any new messages it gets (continued motion) it will keep resetting the timer. On timeout, it sends a different message, use that (use a switch node to filter it out) to turn the light off.

Thanks for the answer.
I did install the timeouttrigger. It is working fine.

But i can not find or don’t know how to do a “switch node” so I’m not able to switch off the light

I tried this but at time out no switch off the light:

I also tried the change tile, also without succes

You need to check what it is outputting. Hook up a “debug” node and then switch to the debug tab on the right side panel. This will “catch” any message coming down the flow and show you what it is. Sometimes it’s “off”, sometimes it’s “Off” etc. The switch node will attempt to match a value, and “divert” it to one of it’s outputs. You can also change “==” to “contains” for a little looser matching.

Thanks again. It is working now.
It says “on” when on but “0” (zero) at off.
I didn’t expect that i did expect “off”

Again thanks. I’m happy