"Trash Mode" kind of feature for Contact Sensors

I have contact sensor on my study door. current setup: open door → turn on lights, close door → turn off lights. this is good if i quickly want to pick up something from the study room, but not good if i want to close the door and sit in the room (for working, reading etc) since lights are off when i close the door. what i would like to see is a feature like “trash mode” on the wyzelock. i.e., i open, close, open the study door and then close door after that should not trigger ‘turn off lights’. but again open & close should trigger it. (i.e., when I am done in the room and exiting from there)