Ein hallo an alle,
Ich bräuchte mal Hilfe von einem Profi:
Ich habe mir eine Markdown Karte angelegt, die mir die Unwetter Warnungen anzeigt - Code hab ich ausm Netz.
Funktioniert auch, allerdings möchte ich die Karte so bearbeiten daß sie mir aus Platzgründen nur das Wichtigste anzeigt.
Den ausführlichen Text konnte ich rauslöschen.
Jetzt möchte aber noch die Warnstufe (Zahl) bearbeiten. Da soll stehen „Warnstufe 2“.
Wenn nicht möglich, dann die Zahl weg.
Ausserdem soll sich die gesamte Karte dynamisch in der Länge je nach Text automatisch anpassen.
(Der (rote) Text ist manchmal einzeilig/zweizeilig)
Hier der Code:
type: markdown
content: >-
{% set current_count = state_attr("sensor.stadt_pforzheim_aktuelle_warnstufe",
"warning_count") %}
{% set advance_count = state_attr("sensor.stadt_pforzheim_vorwarnstufe",
"warning_count") %}
{% if ((current_count == 0 or current_count == None) and (advance_count == 0
or advance_count == None)) %}
**<font color=#44739e>Keine Warnungen</font>**
{% else %}
{% for i in range(current_count) %}
{% set headline = state_attr("sensor.stadt_pforzheim_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor.stadt_pforzheim_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor.stadt_pforzheim_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_start") | as_timestamp %}
{% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
{% set time_end = state_attr("sensor.stadt_pforzheim_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
{% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
**<font color=red><font size=4>{{ headline }}</font>**
*<font color=yellow><font size=5>{{
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1]
~ ", " ~ time_start | timestamp_custom("%H:%M") ~ " - " ~
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1]
~ ", " ~ time_end | timestamp_custom("%H:%M") }}</font>*
{{ 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.stadt_pforzheim_vorwarnstufe", "warning_" ~ loop.index ~ "_headline") %}
{% set description = state_attr("sensor.stadt_pforzheim_vorwarnstufe", "warning_" ~ loop.index ~ "_description") %}
{% set level = state_attr("sensor.stadt_pforzheim_vorwarnstufe", "warning_" ~ loop.index ~ "_level") %}
{% set time_start = state_attr("sensor.stadt_pforzheim_vorwarnstufe", "warning_" ~ loop.index ~ "_start") | as_timestamp%}
{% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
{% set time_end = state_attr("sensor.stadt_pforzheim_vorwarnstufe", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
{% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
**<font color=#fdd835>{{ headline }}</font>**
*<font color=gray>{{
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1]
~ ", " ~ time_start | timestamp_custom("%H:%M") ~ " - " ~
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1]
~ ", " ~ time_end | timestamp_custom("%H:%M") }}</font>*
{{ description|trim }}
{% if not loop.last %}
***
{% endif %}
{% endfor %}
{% endif %}
grid_options:
columns: 12
rows: 3
visibility:
- condition: states
entity: sensor.stadt_pforzheim_aktuelle_warnstufe
states: 0<
Ich weiß nicht ob meine Wünsche überhaupt machbar sind, aber ich frage halt mal.
Gruß Jürgen