Hurricane Warning Notification Automation

Automation that finds all Tropical Cyclones in the GDAC integration and sends a notification to all devices

Hurricane Automation Code
description: ""
trigger:
  - platform: time
    at: "06:00:00"
condition:
  - condition: template
    value_template: >-
      {{ states.geo_location | selectattr('attributes.source', 'eq', 'gdacs') |
      selectattr('attributes.event_type', 'eq', 'Tropical Cyclone') | list |
      length > 0 }}
action:
  - service: notify.notify
    metadata: {}
    data:
      title: >
        {{states.geo_location | selectattr('attributes.source', 'eq', 'gdacs') |
        selectattr('attributes.event_type', 'eq', 'Tropical
        Cyclone')|list|count}} Hurricanes Detected
      message: >
        {% set list1 =  states.geo_location | selectattr('attributes.source',
        'eq', 'gdacs') | selectattr('attributes.event_type', 'eq', 'Tropical
        Cyclone')|sort(attribute='state', reverse=true)|
        map(attribute='attributes')|map(attribute='friendly_name') | list  %}

        {% set list2 = states.geo_location | selectattr('attributes.source',
        'eq', 'gdacs') | selectattr('attributes.event_type', 'eq', 'Tropical
        Cyclone')|sort(attribute='state', reverse=true)| map(attribute='state')
        | list %}

        {% set list3 = states.geo_location | selectattr('attributes.source',
        'eq', 'gdacs') | selectattr('attributes.event_type', 'eq', 'Tropical
        Cyclone')|sort(attribute='state', reverse=true)|
        map(attribute='attributes')|map(attribute='severity') | list %}


        {% set combined_list = namespace(value='') %}

        {% for index in range(list1 | length) %}
            {% set combined_item = list1[index] ~ ' ' ~ list2[index] ~ 'mi ' ~ list3[index] %}
            {% set combined_list.value = combined_list.value + combined_item + '\n' %}
        {% endfor %}


        {{ combined_list.value[:-1] }}
mode: restart```
1 Like