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

Great! And do you know how to do when a Wild fire for example is less than 50 km from home? I do something like this but it seem is not working:

condition: template
value_template: >-
  {{ states.geo_location | selectattr('attributes.source', 'eq', 'gdacs') |
  selectattr('attributes.event_type', 'eq', 'Wild Fire') | list | length < 50 }}
 

Hello,

Many thanks for sharing this automation. I have try to use this yaml in my automation by just copy/pasting this in my automation.yaml, but I get some errors at the beginning and end of the .yaml


and can’t save the automation. Do you know what can be the problem?

Many thanks in advance for any support!

Hi,

Many thanks for sharing this automation. I have try to use this yaml in my automation by just copy/pasting this in my automation.yaml, but I get some errors at the beginning and end of the .yaml and can’t save the automation.

Do you know what can be the problem?
Many thanks in advance for any support!

image_2024-10-29_082254679
image_2024-10-29_082254679
770×170 8.38 KB