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.
Leider wird die 3 Karte nicht ausgeblendet, obwohl es aktuell nur die ersten beiden Warnungen gibt.