Moin zusammen!
Ich habe mir vor einigen Tagen die Integration “DWD-Unwetterwarnung” installiert und auch das Markdown aus dem entsprechenden YT-Tutorial eingepflegt. Das Ergebnis ist das folgende:
Wie man sieht, funktioniert die aktuelle Warnstufe (obere Hälfte) gut und auch die Formatierung ist korrekt.
Der Sensor für die Vorhersage (untere Hälfte) zieht auch Daten, aber die Formatierung spinnt hier völlig.
Ich habe den Code der Vorwarnstufe zigfach studiert, aber ich finde den Fehler nicht:
type: markdown
content: |2-
{% set level_colors = {0:'#c5e566', 1:'#ffeb3b', 2:'#fb8c00', 3:'#e53935', 4:'#880e4f', 20:'#fe68fe', 50:'#fe68fe'} %}
{% set current_count = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_count") %}
{% set advance_count = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_count") %}
{% if ((current_count == 0 or current_count == None) and (advance_count == 0 or advance_count == None)) %}
**<font color={{ level_colors[0] }}>Keine Warnungen</font>**
{% else %}
{% for i in range(current_count) %}
{% set headline = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_description") %}
{% set level = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_start") %}
{% set time_end = state_attr("sensor.dwd_weather_warnings_105112000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_end") %}
**<font color={{ level_colors[level] }}>{{ headline }}</font>**
{{ time_start.strftime("%a %H:%M") ~ " - " ~ time_end.strftime("%a %H:%M") }}
*{{ description|trim }}*
{% if not loop.last %}***{% endif %}
{% endfor %}
{% if ((current_count != 0) and (advance_count != 0)) %}***{% endif %}
{% for i in range(advance_count) %}
{% set headline = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_" ~ loop.index ~ "_description") %}
{% set level = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_" ~ loop.index ~ "_start") %}
{% set time_end = state_attr("sensor.dwd_weather_warnings_105112000_vorwarnstufe", "warning_" ~ loop.index ~ "_end") %}
**<font color={{ level_colors[level] }}>{{ headline }}</font>**
{{ time_start.strftime("%a %H:%M") ~ " - " ~ time_end.strftime("%a %H:%M") }}
*{{ description|trim }}*
{% if not loop.last %}***{% endif %}
{% endfor %}
{% endif %}
Findet Ihr hier vielleicht den Grund, weshalb die untere Hälfte nicht korrekt formatiert ist?
Danke und beste Grüße!
Stefan








