DWD Warning Template Karte

Hallo zusammen,

ich versuche gerade eine Karte zu erstellen, die mir die Wetterwarnungen vom DWD anzeigt. Dies funktioniert generell auch. Ich will jedoch, dass die jeweiligen Karten nur eingeblendet werden, wenn auch eine Warnung vorliegt.

Mein Code sieht wie folgt aus:

type: vertical-stack
cards:
  - type: custom:mushroom-template-card
    primary: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_headline') }}"
    picture: >
      {% set name = state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_name') | lower | replace(' ', '_') | replace('ä', 'ae') | replace('ö', 'oe') | replace('ü', 'ue') | replace('ß', 'ss') %}
      {{ '/local/Wetterwarnung/warn_icons_' + name + '.png' }}
    card_mod:
      style: |
        ha-card {
          background-color: {{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_color') }} !important;
        }
        :host {
          {% if state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_color') == '#ffeb3b' %}
            --primary-text-color: #000000 !important;
            --secondary-text-color: #000000 !important;
          {% else %}
            --primary-text-color: #ffffff !important;
            --secondary-text-color: #ffffff !important;
          {% endif %}
          font-weight: bold;
          font-size: 18px;
        }
    entity: sensor.stadt_koeln_aktuelle_warnstufe
    tap_action:
      action: more-info
    conditions:
      - condition: template
        value_template: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_name') is not none and state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_1_name') != '' }}"

  - type: custom:mushroom-template-card
    primary: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_headline') }}"
    picture: >
      {% set name = state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_name') | lower | replace(' ', '_') | replace('ä', 'ae') | replace('ö', 'oe') | replace('ü', 'ue') | replace('ß', 'ss') %}
      {{ '/local/Wetterwarnung/warn_icons_' + name + '.png' }}
    card_mod:
      style: |
        ha-card {
          background-color: {{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_color') }} !important;
        }
        :host {
          {% if state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_color') == '#ffeb3b' %}
            --primary-text-color: #000000 !important;
            --secondary-text-color: #000000 !important;
          {% else %}
            --primary-text-color: #ffffff !important;
            --secondary-text-color: #ffffff !important;
          {% endif %}
          font-weight: bold;
          font-size: 18px;
        }
    entity: sensor.stadt_koeln_aktuelle_warnstufe
    tap_action:
      action: more-info
    conditions:
      - condition: template
        value_template: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_name') is not none and state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_2_name') != '' }}"

  - type: custom:mushroom-template-card
    primary: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_headline') }}"
    picture: >
      {% set name = state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_name') | lower | replace(' ', '_') | replace('ä', 'ae') | replace('ö', 'oe') | replace('ü', 'ue') | replace('ß', 'ss') %}
      {{ '/local/Wetterwarnung/warn_icons_' + name + '.png' }}
    card_mod:
      style: |
        ha-card {
          background-color: {{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_color') }} !important;
        }
        :host {
          {% if state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_color') == '#ffeb3b' %}
            --primary-text-color: #000000 !important;
            --secondary-text-color: #000000 !important;
          {% else %}
            --primary-text-color: #ffffff !important;
            --secondary-text-color: #ffffff !important;
          {% endif %}
          font-weight: bold;
          font-size: 18px;
        }
    entity: sensor.stadt_koeln_aktuelle_warnstufe
    tap_action:
      action: more-info
    conditions:
      - condition: template
        value_template: "{{ state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_name') is not none and state_attr('sensor.stadt_koeln_aktuelle_warnstufe', 'warning_3_name') != '' }}"

Meine Karte sieht so aus.
Screenshot 2025-02-02 205904

Leider wird die 3 Karte nicht ausgeblendet, obwohl es aktuell nur die ersten beiden Warnungen gibt.

Ich kenne mich mit mushroom-template-card nicht aus.
In meinen Karten in den Abschnitten benutze ich “state_not: unavailable” bzw. “state_not: unknown” zum Ausblenden von Karten.
vielleicht hilft es dir.

Du kast Dir das mit Meteoalarm zusammen basteln, funktioniert bei mir sehr gut.

type: custom:meteoalarm-card
entities:
  - entity: sensor.dwd
integration: dwd
hide_caption: false
override_headline: false
hide_when_no_warning: true

Warum nimmst du nicht als Bedingung den Nummerischen Zustand?

condition: numeric_state
entity: sensor.stadt_koeln_aktuelle_warnstufe
above: 0

Die hatte ich mir auch schon angeguckt.

Was mich stört ist, dass für mehrere Warnungen dieselben Icons genutzt werden. Würde schon gerne für jede Warnung die "offiziellen vom DWD nutzen.