How to clear a persistent_notification after some set time automatically, without delay

Hey, pre HAS 2023.6, persistent_notification were in the state machine, thus we could check that it’s state was in a certain state for: minutes: 10 for example.

How can we do this now? I have a few low key notifications that I want to drop off after 10 minutes. after a few failed attempts and lots of digging, best I could come up w/ is using a delay, which may have it’s own issues.

Here’s my current automation - the desire is to remove the delay and have it handled in the trigger, so that this thing isn’t even triggered until needed.

#####
# Handles closing some low value alerts
#
#####

alias: Auto Close Alerts
id: 4180ff1a-4cab-4e5f-ab66-8361cad83f74

trigger:
  # cannot check state as of 2023.6, cannot check if in state of X time.. 
  alias: Persistent notifiation added
  trigger: persistent_notification
  update_type:
    - added

conditions:
  - and:
      - alias: Certain notifications only
        condition: template
        value_template: >
          {{ trigger.notification.notification_id in
            [
              'dishwasher_done',
              'dryer_done',
              'rolo_done'
            ] 
          }}

action:
  - alias: Wait 1 minute
    delay:
      seconds: 10
  
  # logic is error prone, potentially we could be clearing a brand new alert..
  - action: persistent_notification.dismiss
    data:
      notification_id: "{{ trigger.notification.notification_id }}"

Hi poat,

To clear a persistent notification, there is an available action. persistent_notification.dismiss
See the Docs here:

I am doing that in my automation above. I was wondering if there was a better way that didn’t involve a delay timer