xlcnd / meteoalarmeu

A 'custom component' for Home-Assistant for Weather Warnings from meteoalarm.eu
GNU General Public License v3.0
20 stars 3 forks source link

Automation to dismiss obsolete PNs #14

Closed xlcnd closed 3 years ago

xlcnd commented 3 years ago
- 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 -%}