Mutiple Timers Triggered. How to prioritize?

I have 2 timers to trigger a switch off. This is all for my garage which is also my main gate entrance. Timers are triggered only after 10pm. First timer is triggered by a motion sensor if someone goes home after 10pm which turns off the switch after 40 secs. The second timer is triggered by geolocation if someone arrives from car which turns off the switch after 7 minutes: these are in my config yaml.

timer:
  bhaussala:
    duration: 00:05:00
  garage:
    duration: 00:00:40
  goingingarage:
    duration: 00:07:00

The going in garage is longer than 40 seconds but it is triggered first upon arriving home. But still upon trigger of the motion sensor the light gets turn off by the switch because the timer is lesser than 7 minutes.

these are my automation configuration.

- alias: Turn on Garage if there is movement after 10 PM
  trigger:
  - platform: state
    entity_id: binary_sensor.garage_motion, binary_sensor.2nd_floor_to_garage_motion
    to: 'on'
  condition:
  - condition: time
    after: '22:00:00'
    before: 05:30:00
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    - sat
    - sun
  action:
  - service: homeassistant.turn_on
    data:
      entity_id:
      - switch.garage
  - service: timer.start
    data:
      entity_id: timer.garage
  id: e8cc3c72d1234ec9b76e75b77d43da45
- alias: Turn Off Garage 40 Seconds after trigger
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.garage
  condition:
  - condition: time
    after: '22:00:00'
    before: 05:34:00
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    - sat
    - sun
  action:
  - service: homeassistant.turn_off
    data:
      entity_id:
      - switch.garage
  id: bc8e4560c8dc49a6ab0e149a198f1235
- alias: Turn Off Garage 7 minutes after trigger
  trigger:
  - platform: event
    event_type: timer.finished
    event_data:
      entity_id: timer.goingingarage
  condition:
  - condition: time
    after: '22:00:00'
    before: 05:34:00
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    - sat
    - sun
  action:
  - service: homeassistant.turn_off
    data:
      entity_id:
      - switch.garage
  id: 0b6e1bb477404f2d8864f4b4d4046e9f
- id: '1628342634450'
  alias: Turn on the lights when going home after 10 P.M.
  description: ''
  trigger:
  - platform: zone
    entity_id: device_tracker.itel_p682lp
    zone: zone.home
    event: enter
  condition:
  - condition: time
    after: '22:00:00'
    before: 05:45:00
  action:
  - service: homeassistant.turn_on
    target:
      entity_id:
      - switch.garage
    data: {}
  - service: timer.start
    data:
      entity_id: timer.goingingarage

Is there a way to disable one timer if the other event is triggered? Anyone can shed light or point me to somewhere else I can start with? Thank you in advance!

I’m not sure but i think you can use the 7 minute timer state in the 40 second timer automation to prevent the automation from running if the 7 minute timer is active.

Just use one timer and set the duration in the service call. So for the arrive home automation do this:

service: timer.start
data:
  entity_id: timer.garage_light
  duration: '00:07:00'

And for the motion one do this:

if:
  condition: state
  entity_id: timer.garage_light
  state: idle
then:
  service: timer.start
  data:
    entity_id: timer.garage_light
    duration: '00:00:40'

That way the arrive home one will always turn the light on for 7 minutes and the motion one will only do something if the timer isn’t running. And you don’t have to try and deal with timer conflicts because they both just use the same timer.