Auto Light for Night

Hi Guys,
during night I want to turn on the bath light when a security sensor is tripped (from bed to bath) and turnoff after 30 sec when is again tripped (to bath to bed).

– Sensor Tripped (don’t accept new trip for 40sec)
– Turn On Light
– Sensor Tripped
– Wait 30sec
– Turn Off Light

Please help me!
Thanks!

What if a second person trips the sensor rather than the first person returning?

after the first trip for 40 seconds must not accept new trip… I don’t have others ideas

I use PLEG …
My Motions sensors set the dimmable lights to very low if I get to go to the bathroom at night, including the lights in the batroom.
It’s hard on the eyes to turn the bathroom lights on full when you just awake. But my lights stay on longer than 30 seconds … But since there not very bright that does not bother anyone.