Run automation after condition holds true for x seconds not true

Hi.
I have the following automation:-

- id: '1635414627791'
  alias: Turn off aircon when any door or window opened
  description: ''
  trigger:
  - type: opened
    platform: device
    device_id: 19339859d4d94085b07f9088b4e3d301
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
  condition:
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off
    state: 'on'
    for:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
  action:
  - service: remote.send_command
    target:
      entity_id: remote.living_room_remote
    data:
      device: aircon
      command: turn_off
  mode: queued
  max: 10

I have a door sensor on the air con and the back door. When the back door is open for 15 seconds and the air con sensor is open as well, I want to execute the turn_off command. It doesn’t seem to be working. What am I doing wrong?

You’ll want something like this:

- id: '1635414627791'
  alias: Turn off aircon when any door or window opened
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    to: 'on'
  - platform: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off
    to: 'on'
    for: '00:00:15'
  condition:
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off
    state: 'on'
    for: '00:00:15'
  - condition: state
    entity_id: binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    state: 'on'
  action:
  - service: remote.send_command
    target:
      entity_id: remote.living_room_remote

What you have currently will only trigger if binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off goes to on if binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off has already been on for at least 15 seconds.

Alternatively, you could do this:
Create a group with those two sensors…

group:
  aircon_sensors:
    entities:
    - binary_sensor.lumi_lumi_sensor_magnet_aq2_acbc7507_on_off
    - binary_sensor.lumi_lumi_sensor_magnet_aq2_on_off
    all: true

…then use this automation:

- alias: Turn off aircon when any door or window opened
  trigger:
  - platform: state
    entity_id: group.aircon_sensors
    to: 'on'
    for: '00:00:15'
  action:
  - service: remote.send_command
    target:
      entity_id: remote.living_room_remote

That will trigger when the group’s state goes to on for 15 seconds, and because I set all: true in the group, the group will only turn on if all sensors are on. That doesn’t quite match what you’re looking for, but it might be acceptable.