I just encountered a tiny snag with your numbers…
Lets say:
1:00 = Enter the room = Light comes on
1:01 = Leave the room = Light stays on
1:21 = Room still vacant = Light turns off (20 min timer)
1:25 = Enter the room = Light REMAINS off (hasn’t been 30 min)
1:31 = Still in room = Light finally turns on (30 min mark)
Is this scenario acceptable to you?