Clearing a Notification automatically

Hi Not sure I fully understand if this is possible. Using an examplke of say a door with a sensor open or closed. If I get a notification message on the phone based on my automation that the door has been left open. Is there a way that once the door is closed again the notification dissapears?

Yep, use the clear notification command:

To pile onto brooksben11’s reply, if you are using an alert entity put the clear_notification command in the done_message: parameter and mobile notifications will be cleared automatically when the alert is no longer active.

alert:
  garage_door:
    name: Garage is open
    done_message: clear_notification
    entity_id: input_boolean.garage_door
    state: "on"
    repeat: 30
    can_acknowledge: true
    skip_first: true
    notifiers:
      - ryans_phone
      - kristens_phone

Thanks for help. I have this but it is not working. I am right in assuming that this can actually send a command to your phone to remove an existing message?
I am using an automation rather than an Alert - Is that maybe where I have it wrong?

alias: Dismiss Main Gate Notification
description: Dismiss notification when the Main Gate is closed
trigger:
  - platform: state
    entity_id: binary_sensor.shellydw2_483fda81e506_door
    from: "off"
    to: "on"
condition: []
action:
  - data:
      message: clear_notification
      data:
        tag: main_gate_notification
    action: notify.mobile_app_davidsphone
mode: single

is this the same tag used in the original notification you wish to clear?

This is the automation so Yes I believe so. Perhaps there is something on the phone blocking it?

alias: Main Gate Notification
description: Notify apps when the Main Gate is Open
trigger:
  - platform: state
    entity_id:
      - binary_sensor.shellydw2_483fda81e506_door
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 1
      seconds: 0
condition: []
action:
  - data:
      message: Main Gate Open
      data:
        tag: main_gate_notification
    action: notify.mobile_app_davidsphone
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_event
        event_data:
          action: Main_Gate_open
    timeout:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
    continue_on_timeout: false
  - data:
      message: Main Gate is Open
      data:
        tag: main_gate_notification
    action: notify.mobile_app_davidsphone
mode: restart

Shouldn’t clearing be triggered by state change from on to off instead?
What you posted would send clear immediately when it opens, and notification when it is opened for 1 minute.

Thank you. I think I was so tied up with whether the Android system was capable I missed the glaringly obvious. Much appreciated…