How to run an automation every X minutes when a binary sensor is 'on'

So, I’m getting into configuraing and playing around with Tensorflow. I’ve got it working, and have the scan interval set to a high number (20000). I want to set up an automation that manually scans every 5 minutes when an object it detected. My current set up is like so

automation
- alias: Object Detection in the Backyard
  trigger:
  - platform: state
    entity_id: binary_sensor.backyard_line_crossing
    to: 'on'
  condition:
  - condition: numeric_state
    entity_id: sensor.ha_runtime_in_minutes
    above: 1
  action:
  - service: image_processing.scan
    entity_id: image_processing.tensorflow_back_yard

and a binary sensor
 - platform: template
   sensors:
     objects_in_backyard:
       friendly_name: Objects in backyard
       value_template: "{{ states('image_processing.tensorflow_back_gate') | float >= 1 }}"
       entity_id: image_processing.tensorflow_back_gate

My goal is to ultimately have an automation that only runs when I’m away (i’ve got that part), that will notify me when the binary sensor becomes true, but then continue to scan every 5 minutes until it’s false.

In real world terms I want to know if a car is parked in my parking area when I’m away. And I want to know when they leave.

So… Run every 5 minutes when the binary sensor is on

The simplest way I can think of:

Have an automation that by default is triggered every 5 minutes but has a condition based on the state of your binary sensor, so no action would be executed unless that condition is met.

You could have another automation that enables/disables this 5minute automation based on your presence so it only runs when you are away.