Lights with Motion and a delay

I have some automation that turns on a light when I start to walk upstairs and it worked great. Well until I tried to turn the light off and since I’m still close to the motion sensor it turn right back on. I tried to use a virtual switch to fix this, but think my logic is off. The issue is I think it takes a couple seconds to trigger this automation and since I’m standing next to the motion sensor it just turns it back on before the automation kicks off. If I hide and turn off the switch, wait 2 seconds, then it seems to work. Maybe I need a virtual light switch to vs the real light switch?

I think the easiest way is to change the default “re-trigger” on the motion detector. For instance, if you set that to something like 15 seconds to re-trigger after a trigger, you would have 15 seconds to pass the sensor.

Thanks for the idea! I did get my rules working right and just had to modify them a little. I have a rule to turn on lights and set a virtual switch and another rule to turn off the lights and the virtual switch.