Trying to figure out sensor templates for smarter motion trigger notifications

Hi, I would appreciate some feedback/help.

I am trying to smarten up my security automations/notifications by reducing false positives.
I have a number of motion detectors outside, and everything works generally well. I do, however, get false positives from wind moving plants and bugs flying into cameras due to their IR at night. (I am aware of the AI object detection options for cameras and will dabble with that at some stage).

I have a binary sensor helper group called Motion Sensors External that contains all the individual devices.

What I am trying to do now, with template sensors, is answer these two questions:

  1. within the last 10 seconds, have multiple devices triggered a motion event?
  2. within the last 10 seconds, has a single devices triggered more than once (count)?

What I have at the moment, is this:

sensor:
  - platform: template
    sensors:
      multiple_motion_triggers_external:
        friendly_name: 'Multiple Motion Triggers External'
        value_template: >
          {%- set counter = namespace(total=0) %}
          {%- for sensor in expand('binary_sensor.motion_sensors_external') | map(attribute='last_changed') %}
            {%- if now() - sensor < timedelta(seconds=10) %}
              {%- set counter.total = counter.total + 1 %}
            {%- endif %}
          {%- endfor %}
          {{ iif(counter.total > 1, true, false) }}
  - platform: history_stats
    name: Motion Triggered External Count Last 10 Seconds
    entity_id: binary_sensor.motion_sensors_external
    state: "on"
    type: count
    end: "{{ now() }}"
    duration: "00:00:10"

The first template sensor works fine I believe, and I get a “True” if more than one device triggers.

But I am having an issue with the history stats template, it doesnt work (with the 10 second spec) - and I believe this is because of my “recorder” setting, which has “commit_internal: 60”. Would this be correct? Is the history stat dependant on the recorder, and if the timeframe is less than the commit interval, it will never register?

If I dont use the history stat to determine the number of times a device triggered within a timeframe, how else can I achieve this?
Any other better way to answer the two questions above?