Automation sequencing-lights, motion, door sensors

I have a storage room where the light turns on when opening the door (which is what I want), and sometimes I will work in that room for a while with the door closed, sometimes I am in and out–therefore door closing event is not a good trigger. I want the lights to turn off after 10 minutes as long as there has been no motion detected in the room for the last 5 minutes. I am trying to consolidate in the most efficient fashion the following to occur through preferably a single automation:

  1. Door sensor detects door open event, light turns on
  2. Light turns off after 10 minutes if no motion (motion binary sensor is in room) has been detected for 5 minutes (not dependent on door status)

Thanks for any help.