Help with enable automation if another automation was not triggered?

Hey people,
I got two sensors for my front door and security gate
I setup an automation that if the front door opens, and if the security gate is open then to turn on the light. (incase the gate is open then the light will turn on. but if we open the front door to allow air to come in the house and the gate is closed to not turn on the light)

Now the second automation is for the security gate.
if the front door is closed then turn on the light.
if the front door is open, but the first automation was not triggered then turn on the light.
if the front door is open but the first automation was triggered then do nothing.
can anyone help with this ?

First automation:

alias: Front door light (contacts)
description: ''
trigger:
  - type: opened
    platform: device
    device_id: a7223aaa6640076ed71b7924d11f5ebb
    entity_id: binary_sensor.front_door_contact
    domain: binary_sensor
condition:
  - condition: sun
    before: sunrise
    after: sunset
  - type: is_open
    condition: device
    device_id: e09a646bed9be9ed622d1f61d33f596a
    entity_id: binary_sensor.front_door_gate_contact
    domain: binary_sensor
  - condition: device
    type: is_off
    device_id: 4c968000db6a8557e6b1fc6253344c42
    entity_id: switch.sonoff_mini_fd_2
    domain: switch
action:
  - type: turn_on
    device_id: 4c968000db6a8557e6b1fc6253344c42
    entity_id: switch.sonoff_mini_fd_2
    domain: switch
  - delay:
      hours: 0
      minutes: 1
      seconds: 20
      milliseconds: 0
  - condition: device
    type: is_on
    device_id: 4c968000db6a8557e6b1fc6253344c42
    entity_id: switch.sonoff_mini_fd_2
    domain: switch
  - type: turn_off
    device_id: 4c968000db6a8557e6b1fc6253344c42
    entity_id: switch.sonoff_mini_fd_2
    domain: switch
mode: single

I personally think that using the triggering of the first automation as a condition is too complicated.

Why not just use the state of the two entities since ultimately that’s what you seem to be doing but using the automation triggering as a proxy?

to use the automation trigger you would need to know it’s last triggered time. that’s easy to get.

but then you would need to decide how long in the past that you would want to limit that.

would it meet the condition if it had triggered in the last 30 seconds, 2 minutes, 1 hour, 1 day?

Then you would need to compare the last triggered time to now taking into account the offset decided above.