Moin,
Weiß jemand wie man in einer Markdown Card einen automatischen Zeilenumbruch hinbekommt?
Auf dem PC wird der Text einwandfrei angezeigt - auf meinem Smartphone wird ein Teil einfach abgeschnitten.
Danke
Volker
Moin,
Weiß jemand wie man in einer Markdown Card einen automatischen Zeilenumbruch hinbekommt?
Auf dem PC wird der Text einwandfrei angezeigt - auf meinem Smartphone wird ein Teil einfach abgeschnitten.
Danke
Volker
Der autom. Zeilenumbruch sollte imho immer erfolgen.
Ansonsten einfach 2x schalten, nicht nur 1x.
Zeig mal dein Markdown-Code.
Ja, der Umpruch erfolgt ja auch automatisch… Allerdings wird der Text beim Smartphone abgeschnitten.
So siehts am PC aus:

Am Smartphone wird es dann so abgeschnitten (hinter 0°C):

Und hier mein Code - Die eigentlich Ausgabe des Warn-Textes ist nur eine Zeile
{{ description|wordwrap(40) }}<br>
Mit “wordwrap” hab ich erst mal einen Workaround gefunden. Ein Zeilenumbruch (abhängig vom Endgerät) wäre natürlich besser.
Hier der ganze Code:
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
description|wordwrap(40) schneidet den Text ab.
Nein, das habe ich eingefügt, damit der Text NICHT abgeschnitten wird.
Dadurch wird ein automatischer Zeilenumbruch generiert, falls die Zeile sonst länger als 40 Zeichen würde.
Klappt einwandfrei und ist mit max 40 Zeichen für das Smartphone optimal… für den PC etwas zu kurz.
Moin Dupliziere die Karte.
Einmal mit wordwrap einmal ohne und dann lässt du basierend auf dem Bildschirm nur eine anzeigen.

LG
Tobi
Gute Idee - wäre ein Workaround
Danke!