Create a cooldown from a switch and an occupancy sensor

I bought a new switch for the hallway and it has a radar sensor built in, and a normal switch.
The hallway always has some ambient lights on during the winter so most of the times we don’t need to turn on the lights if we are just passing through.
But if we do turn on the lights then I want to try and use the radar to detect occupancy and switch off the lights after 5 minutes.

My thoughts are that I trigger on switch.hall_switch and when this is on the radar (binary_sensor.hall_switch_ias_zone) should also be on, lets assume it always is, the sensor has 1 minute cooldown, but I want it to be 5.
Most other automations use the occupancy sensor and you can set the mode to restart but since I want the start of my automation to be the actual switch, what are my options?
I can’t really think of what to do. I started thinking of a triggered template sensor but does not seem to work.
Is it a wait for trigger binary sensor = off for 5 minutes? Is that my only option?
I was hoping I didn’t have to use waits and delays.
I’m probably missing something obvious here.

If this is the case, shouldn’t the trigger be binary_sensor.hall_switch_ias_zone?

Then you can simply have

triggers:
  - trigger: state
    entity_id:
      - binary_sensor.hall_switch_ias_zone
    to:
      - "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0

No need for restart.

2 Likes

Ahhh… you mean as the switch off automation. Yes that makes sense.
I was thinking of the whole flow, but you are right, the automation shouldn’t care about the on.
I can even add a condition that the switch is on to make sure the automation doesn’t trigger when it shouldn’t