Automation for garage door with occupancy sensor

Hi All

I just built a mmWeave sensor for my garage that basically check the room occupancy. Now 1. I’m trying to set up an automation for my garage cover and I’m having a lot of problem.

Basically the automation is simple: if the garage cover was left open for a certain time and there is no motion in the garage (means that nobody is inside the garage) then it should close the cover.
This is what I did so far:

alias: "Garage: chiusura garage automatica"
trigger:
  - platform: state
    entity_id:
      - cover.garage_door
    to: open
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.garage_presence
    to: "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0
condition:
  - condition: state
    entity_id: binary_sensor.garage_presence
    state: "off"
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - condition: state
    entity_id: cover.garage_door
    state: open
action:
  - service: notify.mobile_app_iphone_di_luca
    data:
      message: :bangbang: GARAGE RIMASTO APERTO :bangbang:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.garage
mode: single

This automation basically works, but I’m having few issues and I don’t know how to solve:

  • the problem is that I don’t know how to tell to stop the automation if for example the mmWave detect my presence after the autormation was triggered – Like if I’m walking in the garage from the back door I want to stop the cover closing
  • another problem is that if for any reason I manually block the cover (like covering the garage security sensor while the cover is closing) then the automation won’t trigger again since the triggers won’t fire again

Anyone has any idea how to solve this?