GDACS markdown card

In addition to the DWD WarnWetter markdown card i have created a second markdown card which shows the current alerts issued by the Global Disaster Alert and Coordination System (GDACS) near my home.

In the configuration.yaml i activated the gdacs with the following line:

gdacs:

The code for the markdown card is:

type: markdown
content: >-
  {% for state in states.geo_location %}
    {% if state.attributes.source=="gdacs" %}
  <ha-icon icon="{{ state.attributes.icon }}"></ha-icon> **<font color="{{ state.attributes.alert_level }}">{{ state.name }}</font>**

  {{ state.attributes.description }}
  
  *Issued: {{ state.attributes.from_date.strftime("%d.%m.%Y %H:%M") }}*
    {% endif %}
  {% endfor %}
title: GDACS alerts

The result looks like:
gdacs

13 Likes

I added this integration directly from the HA UI so do i need also to put in configuration.yaml?
And more can you share the entire code of your card?

If you add the integration in the UI you don’t need to add it in configuration.yaml, that’s what I did and it worked fine.

The code shared is the entire card btw, if you copy and paste that markdown card into your lovelace UI it should work fine. I’ve been using it just as its shared for a bit now without issue. What’s issue are you encountering?

@stephan19 love the card btw, looks great :+1:

Thanks, yes it’s working very good…
BTW actually i have only two alerts about drought and volcano… if there are more they will be added automatically? (for example earthquake)

Yes. So the way it works is this, it basically draws a circle on the map. The center of that circle is the latitude/longitude point which you provided when configuring that integration and the radius is what you provided there as well. To see what is actually in that circle I found this tool useful.

The integration will then watch the global GDACS feed. Any time an event pops up it comes with a shape describing where on the map that event effects. If the affected area of the event overlaps with your circle then the integration creates a new geo_location.xxxxx entity. That’s what this card is watching for, its showing you all entities available in the domain geo_location. When the event is over or its affected area no longer overlaps with your circle then the integration cleans those entities up.

Therefore you will only see currently active events. What you’re seeing now is the active GDACS events in your specified area. If an earthquake event gets published then you’ll see that but only when there’s actually an earthquake event.

1 Like

Thank you for this card, it works great. Wondering how you would add a clickable link to each GDACS report, so you can see the full details of each alert. For example, I just received an alert for this, and the GDACS site has a full description of it: https://www.gdacs.org/report.aspx?eventtype=TC&eventid=1000735&episodeid=12

Thanks!

EDIT: Ok, I’m pretty new with Python but I think I figured this out based on GDACS report formats. This works for me, I’ll see if it works in the long run. I added this to then end of the above code:

See detailed report <a href="https://www.gdacs.org/report.aspx?eventtype={{ state.attributes.external_id[:2] }}&eventid={{ state.attributes.external_id[2:255] }}">here</a>
2 Likes

Hey, is there a way for it to only show incidents marked as red? So, only the most urgent events in my timeline? That would be swell.

The card? I mean its not actually my card but I assume so. Looking at the template above it includes this inside the for loop:

**<font color="{{ state.attributes.alert_level }}">**

Based on that I assume the alert_level attribute is a color. So should be able to change that if statement inside the for loop to further restrict what you see if you only want to see red ones. Something like this should work:

{% if state.attributes.source=="gdacs" and state.attributes.alert_level == "red" %}

Just to be clear, I can’t test this right now and confirm it actually works since I don’t have a GDACS alert to look at right now. I’m just guessing from the template and the fact that you’re telling me some of them are red. So I’m assuming the red ones have a value of red in alert_level. Try it out though and tweak if necessary.

2 Likes

Thanks, that worked great.

1 Like

Hi. Where and how did you add the “see detailed report” code? Great idea by the way. Thank you.

@scarolaa

It’s been a while since I’ve seen an alert but I believe this still works:

type: conditional
conditions:
  - entity: sensor.gdacs_41_97120095091191_71_30614042282106
    state_not: '0'
card:
  type: markdown
  content: >-
    {% for state in states.geo_location %}
      {% if state.attributes.source=="gdacs" %}
    <ha-icon icon="{{ state.attributes.icon }}"></ha-icon> **<font color="{{
    state.attributes.alert_level }}">{{ state.name }}</font>**

    {{ state.attributes.description }}


    Event: {{  state.attributes.event_type  }}

    Severity/Type: {{ state.attributes.alert_level }}; {{ 
    state.attributes.severity  }}


    See detailed report <a href="https://www.gdacs.org/report.aspx?eventtype={{
    state.attributes.external_id[:2] }}&eventid={{
    state.attributes.external_id[2:255] }}">here</a>



    *Alert Duration: {{ state.attributes.from_date.strftime("%B %d, %Y") }} - {{
    state.attributes.to_date.strftime("%B %d, %Y") }}

    {% endif %} {% endfor %}
  title: GDACS alerts

On a Card, just paste into the Code Editor. I use a conditional card that hides this until the “emergency alerts” entity is >0

3 Likes

Awesome, thank you.
And I learned something new (conditional cards)!
Thank you again.

This card is exactly what I’m looking for, however, it doesn’t seem to be working for me, does anyone see any issue with the code here? All I see is the title.

I’ve tried both the original code in the first post, as well as the conditional code, which is my preference, however both do not show up.

image

When I edit the card/page, both entries are showing me this error:

My code is here:

type: markdown
content: >-
  {% for state in states.geo_location %}
    {% if state.attributes.source=="gdacs" %}
  <ha-icon icon="{{ state.attributes.icon }}"></ha-icon> **<font color="{{
  state.attributes.alert_level }}"> {{ state.name }}</font>**{{
  state.attributes.description }}

  *Issued: {{ state.attributes.from_date.strftime("%d.%m.%Y %H:%M") }}*
    {% endif %}
  {% endfor %}
title: GDACS Alerts

and conditional here:

type: conditional
conditions:
  - entity: sensor.gdacs_home
    state_not: '0'
card:
  type: markdown
  content: >-
    {% for state in states.geo_location %}
      {% if state.attributes.source=="gdacs" %}
    <ha-icon icon="{{ state.attributes.icon }}"></ha-icon> **<font color="{{
    state.attributes.alert_level }}">{{ state.name }}</font>**

    {{ state.attributes.description }}

    Event: {{  state.attributes.event_type  }}

    Severity/Type: {{ state.attributes.alert_level }}; {{ 
    state.attributes.severity  }}

    See detailed report <a href="https://www.gdacs.org/report.aspx?eventtype={{
    state.attributes.external_id[:2] }}&eventid={{
    state.attributes.external_id[2:255] }}">here</a>

    *Alert Duration: {{ state.attributes.from_date.strftime("%B %d, %Y") }} - {{
    state.attributes.to_date.strftime("%B %d, %Y") }}

    {% endif %} {% endfor %}
  title: GDACS Alerts (Conditional)