Automation to dismiss obsolete PNs
xlcnd opened this issue · comments
- alias: Dismiss obsolete PNs about weather warnings
mode: restart
trigger:
- platform: event
event_type: persistent_notifications_updated
- platform: time_pattern
minutes: '/31'
action:
- delay: '00:00:10'
- service: persistent_notification.dismiss
data:
notification_id: >
{%- filter trim(",") -%}
{%- for item in states.persistent_notification if item |regex_search("until \*\*(.*?)\*\*") -%}
{%- if item | regex_search("meteoalarm") -%}
{%- if item | regex_findall_index("until \*\*(.*?)\*\*") | as_timestamp() < as_timestamp(now()) -%}
{{ item.entity_id | replace('persistent_notification.', '') }},
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endfilter -%}