Using motion and contact to turn on light, but how about off?

Use case: I’d like to use two motion sensors placed in the garage and two contact sensors on the doors leading into the garage to turn on the garage lights. So long as I am in the garage (motion), the lights will remain on. If motion is not detected after a period, the light will turn off.

I’ve already created four routines–two on/off routine pairs for when motion is detected (turn on lights) and when motion is not detected (turn off lights).

As I start to create the routines for the door contact sensors (to turn on the light when the door into the garage is opened), I began to wonder if it will work as intended.

  1. Door opens, light triggered on, person enters garage
  2. Motion detected by one of two sensors or both, lights on
  3. Person leaves garage (causing lights to be triggered on, but it’s okay)
  4. Motion not detected either sensor for x minutes, lights turn off.

Is my logic sound? Thanks.