Hier mal der ganze Code. ich hab mir est mal mit einen festen wordwrap nach 40 Zeichen beholfen - gut fürs Smartphone, suboptimal für den PC:
type: vertical-stack
cards:
- type: markdown
content: >-
{% set region= "806433004" %}
{% set weekdays = ["Montag", "Dienstag", "Mittwoch", "Donnerstag",
"Freitag", "Samstag", "Sonntag"] %}
{% set months = ["Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember"] %}
{{ "Es ist " + weekdays[now().weekday()] + ", der " +
now().strftime("%-d") + ". " + months[now().month - 1] + " " +
now().strftime("%Y")+ ", " +now().strftime("%H") + ":" +
now().strftime("%M") + " Uhr"}}
<font size=3px> Wetterwarnung für
{{state_attr("sensor."~region~"_aktuelle_warnstufe", "region_name")}} :
</font>
{% set pre_current_count = state_attr("sensor."~region~"_vorwarnstufe",
"warning_count") %}
{% if (pre_current_count == 0) %}
<font color= #00ff00 size=5px >
Keine Vorwarnung <br>
</font>
{% else %}
<font color= #ff0000 size=5px>
VORWARNUNG
</font>
{% endif %}
{% set current_count = state_attr("sensor."~region~"_aktuelle_warnstufe",
"warning_count") %}
{% if (current_count == 0) %}
<font color= #00ff00 size=5px >
Keine aktuelle Warnung
</font>
{% else %}
<font color= #ff0000 size=5px>
WARNUNG
</font>
{% endif %}
- type: conditional
conditions:
- condition: state
entity: sensor.806433004_vorwarnstufe
state_not: "0"
card:
type: vertical-stack
cards:
- type: markdown
content: >-
{% set region= "806433004" %} <font color= #ff0000
size=5px> VORWARNUNG </font> {% set level_colors = {0:'#c5e566',
1:'#ffeb3b', 2:'#fb8c00', 3:'#e53935', 4:'#880e4f', 20:'#fe68fe',
50:'#fe68fe'} %} {% set current_count =
state_attr("sensor."~region~"_vorwarnung","warning_count") %} {%
if(current_count == 0 or current_count == None) %}
{% set level = 0 %}
{% set todo = "Keine Handlungshinweise" %}
**<font color={{ level_colors[level] }}>{{ todo }}</font>** {% else
%}
{% for i in range(current_count) %}
{% set headline = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_description") %}
{% set todo = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_instruction") %}
{% set level = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_start") | as_timestamp %}
{% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
{% set time_end = state_attr("sensor."~region~"_vorwarnung", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
{% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
<font color={{ level_colors[level] }}>{{ headline }}</font> {{
state_attr("sensor."~region~"_vorwarnung" , 'region_name') }}
<font color=gray>{{
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1]
~ ", " ~ time_start | timestamp_custom("%H:%M") ~ " Uhr - " ~
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1]
~ ", " ~ time_end | timestamp_custom("%H:%M") ~ " Uhr" }}</font>
<hr />
{{ description|wordwrap(40) }}<br>
{{ todo|wordwrap(40) }}
{% if not loop.last %}
<hr />
{% endif %}
{% endfor %}
{% endif %}
- type: conditional
conditions:
- condition: state
entity: sensor.806433004_aktuelle_warnstufe
state_not: "0"
card:
type: vertical-stack
cards:
- type: markdown
content: >-
{% set region= "806433004" %} <font color= #ff0000 size=5px> WARNUNG
</font> {% set level_colors = {0:'#c5e566', 1:'#ffeb3b',
2:'#fb8c00', 3:'#e53935', 4:'#880e4f', 20:'#fe68fe', 50:'#fe68fe'}
%} {% set current_count =
state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_count")
%} {% if (current_count == 0 or current_count == None) %}
{% set level = 0 %}
{% set todo = "Keine Handlungshinweise" %}
**<font color={{ level_colors[level] }}>{{ todo }}</font>** {%
else %}
{% for i in range(current_count) %}
{% set headline = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_description"|trim) %}
{% set todo = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_instruction") %}
{% set level = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_start") | as_timestamp %}
{% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
{% set time_end = state_attr("sensor."~region~"_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
{% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
<font color={{ level_colors[level] }}>{{ headline }} <br></font>
{{ state_attr("sensor."~region~"_aktuelle_warnstufe" , 'region_name') }}
<font color=gray>{{
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1]
~ ", " ~ time_start | timestamp_custom("%H:%M") ~ " Uhr - " ~
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1]
~ ", " ~ time_end | timestamp_custom("%H:%M") ~ " Uhr"}}</font>
<hr />
{{ description|wordwrap(40) }}<br>
{{ todo|wordwrap(40) }}
{% if not loop.last %}
<hr />
{% endif %}
{% endfor %}
{% endif %}
- camera_view: auto
type: picture-glance
entities: []
camera_image: camera.www_dwd_de
- type: picture
image: local/pictures/agenda2.png
title: Wetterwarnung DWD