DWD Warnung Markdown

Hallo,
was muss ich in meinem bestehenden Code einfügen, damit die Tage in der Wetterwarnung in Deutsch angezeigt werden?

Hier mein Code:

{% 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_105978000_aktuelle_warnstufe", "warning_count") %}
  {% set advance_count = state_attr("sensor.dwd_weather_warnings_105978000_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_105978000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_headline") %}
      {% set description = state_attr("sensor.dwd_weather_warnings_105978000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_description") %}
      {% set level = state_attr("sensor.dwd_weather_warnings_105978000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_level") %}
      {% set time_start = state_attr("sensor.dwd_weather_warnings_105978000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_start") %}
      {% set time_end = state_attr("sensor.dwd_weather_warnings_105978000_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_105978000_vorwarnstufe", "warning_" ~ loop.index ~ "_headline") %}
      {% set description = state_attr("sensor.dwd_weather_warnings_105978000_vorwarnstufe", "warning_" ~ loop.index ~ "_description") %}
      {% set level = state_attr("sensor.dwd_weather_warnings_105978000_vorwarnstufe", "warning_" ~ loop.index ~ "_level") %}
      {% set time_start = state_attr("sensor.dwd_weather_warnings_105978000_vorwarnstufe", "warning_" ~ loop.index ~ "_start") %}
      {% set time_end = state_attr("sensor.dwd_weather_warnings_105978000_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 %}

DWD Warnung

Hier mal mein Code

{% set sensor_region_name ="dwd_weather_warnings_105124000" %}

{% set current_last_update = state_attr("sensor." ~ sensor_region_name ~
"_current_warning_level", "last_update") %} {% set weekday_last_update =
as_timestamp(current_last_update) | timestamp_custom("%w", True) | int %}
Stand: {{
['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_last_update-1]
~ ", " ~ as_timestamp(current_last_update) |
timestamp_custom('%d.%m.%Y-%H:%M:%S') }}



{% set sensor_region_name ="dwd_weather_warnings_105124000" %}

{% set current_region_name = state_attr("sensor." ~ sensor_region_name ~
"_current_warning_level", "region_name") %} {% set current_count =
state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level",
"warning_count") %} {% set advance_count = state_attr("sensor." ~
sensor_region_name ~ "_advance_warning_level", "warning_count") %} 

****{{ current_region_name }}****
{% if ((current_count == 0 or current_count == None) and (advance_count == 0 or advance_count == None)) %} **<font color=#c5e566>Keine Warnungen</font>**{% else %}
  {% for i in range(current_count) %}
    {% set headline = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_headline") %}
    {% set description = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_description") %}
    {% set instruction = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_instruction") %}
    {% set level = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_level") %}
    {% set time_start = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_start") %}
    {% set weekday_start = as_timestamp(time_start) | timestamp_custom("%w", True) | int %}
    {% set time_end = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_end") %}
    {% set weekday_end = as_timestamp(time_end) | timestamp_custom("%w", True) | int %}
    {% set color = state_attr("sensor." ~ sensor_region_name ~ "_current_warning_level", "warning_" ~ loop.index ~ "_color") %}
  **<font color={{ color }}>{{ headline }}</font>**     
  **{{ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1] ~ ", " ~ as_timestamp(time_start) | timestamp_custom('%H:%M') ~ " Uhr - " ~ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1] ~ ", " ~ as_timestamp(time_end) | timestamp_custom('%H:%M') ~ " Uhr" }}**
  *{{ description|trim }}*
  {% if (instruction|trim != "None") %}
  ****{{ instruction|trim }}****
  {% endif %}
  {% 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." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_headline") %}
    {% set description = state_attr("sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_description") %}
    {% set instruction = state_attr("sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_instruction") %}
    {% set level = state_attr("sensor.sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_level") %}
    {% set time_start = state_attr("sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_start") %}
    {% set weekday_start = as_timestamp(time_start) | timestamp_custom("%w", True) | int %}
    {% set time_end = state_attr("sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_end") %}
    {% set weekday_end = as_timestamp(time_end) | timestamp_custom("%w", True) | int %}
    {% set color = state_attr("sensor." ~ sensor_region_name ~ "_advance_warning_level", "warning_" ~ loop.index ~ "_color") %}
  **<font color={{ color }}>{{ headline }}</font>**
  **{{ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1] ~ ", " ~ as_timestamp(time_start) | timestamp_custom('%H:%M') ~ " Uhr - " ~ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1] ~ ", " ~ as_timestamp(time_end) | timestamp_custom('%H:%M') ~ " Uhr" }}**
  *{{ description|trim }}*
  {% if (instruction|trim != "None") %}
  ****{{ instruction|trim }}****
  {% endif %}
  {% if not loop.last %}***{% endif %}
  {% endfor %}
{% endif %}

Musst paar Zeilen anpassen, nimm diesen Code:


- type: markdown
    title: Wetterwarnungen
    content: >-      
      {% set current_count = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_count") %}
      {% set advance_count = state_attr("sensor.wetterwarnungen_advance_warning_level", "warning_count") %}
      {% if ((current_count == 0 or current_count == None) and (advance_count == 0 or advance_count == None)) %}
      **<font color=#c5e566>Keine Warnungen</font>**
      {% else %}
        {% for i in range(current_count) %}
          {% set headline = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_headline") %}
          {% set description = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_description") %}
          {% set level = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_level") %}
          {% set time_start = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_start") %}
          {% set weekday_start = as_timestamp(time_start) | timestamp_custom("%w", True) | int %}
          {% set time_end = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_end") %}
          {% set weekday_end = as_timestamp(time_end) | timestamp_custom("%w", True) | int %}
          {% set color = state_attr("sensor.wetterwarnungen_current_warning_level", "warning_" ~ loop.index ~ "_color") %}
        **<font color={{ color }}>{{ headline }}</font>**     
        {{ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1] ~ ", " ~ time_start.strftime("%H:%M") ~ " - " ~ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1] ~ ", " ~ time_end.strftime("%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.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_headline") %}
          {% set description = state_attr("sensor.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_description") %}
          {% set level = state_attr("sensor.sensor.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_level") %}
          {% set time_start = state_attr("sensor.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_start") %}
          {% set weekday_start = as_timestamp(time_start) | timestamp_custom("%w", True) | int %}
          {% set time_end = state_attr("sensor.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_end") %}
          {% set weekday_end = as_timestamp(time_end) | timestamp_custom("%w", True) | int %}
          {% set color = state_attr("sensor.wetterwarnungen_advance_warning_level", "warning_" ~ loop.index ~ "_color") %}
        **<font color={{ color }}>{{ headline }}</font>**
        {{ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_start-1] ~ ", " ~ time_start.strftime("%H:%M") ~ " - " ~ ['Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag','Sonntag'][weekday_end-1] ~ ", " ~ time_end.strftime("%H:%M") }}
        *{{ description|trim }}*
        {% if not loop.last %}***{% endif %}
        {% endfor %}
      {% endif %}

Hallo,

erstmal vielen Dank für die Codes!!!

Ich würde gerne die Karte nur anzeigen wenn auch Warnungen und Vorwarnungen vorhanden sind.
Ich denke das kann ich mit Bedingungen realisieren. Doch nach was muss ich bei den DWD Infos filtern damit sowohl Warnungen als auch Vorwarnungen angezeigt werden aber ansonsten nichts?

Hat jemand einen Tipp.

Viele Grüße
Markus

Bau dir doch einfach eine Bedingungs-Karte drum rum. Im Dashboard über die UI die Bedingungskarte auswählen, dann dort abfragen, wenn die aktuelle Warnstufe über 0.
Der yaml Code sieht dann so ungefähr aus:

type: conditional
conditions:
  - condition: numeric_state
    entity: sensor.dwd_weather_warnings_105124000_current_warning_level
    above: 0
card:
  type: markdown
  content: >-
...
...
...

Ja, perfekt. Passt.

Danke!!!

Hallo zusammen,

die Karten usw. funktionieren bei mir super, jedoch würde ich gerne haben, dass wenn eine Warnung am gleichen Tag anfängt und endet, nicht der Tag zwei mal erwähnt wird.

Momentan ist es also so:

Montag, 07:00 - Montag, 16:00
und soll sein:
Montag, 07:00 - 16:00

image

Zudem hätte ich gerne die Zeit in einer extra Zeile unter der amtlichen Warnung. Mit welchem Befehl bekomme ich linebreaks?

Leider sind alle meine versuche einen if-Block einzubauen um weekday_start und weekday_end zu vergleichen und dann eine andere Ausgabe einzubauen… Jetzt an einem Tag ohne Warnung noch schwerer nachzustellen. Wie macht ihr denn sowas? Manipuliert ihr für Tests dann eure Sensoren bzw. nutzt dann Variablen dafür?

Mein aktueller Code sieht wie folgt aus:

{% set level_colors = {1:'#ffeb3b', 2:'#fb8c00', 3:'#e53935', 4:'#db0bae', 20:'#fe68fe', 50:'#fe68fe'} %}
                  {% set current_count = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_count") %}
                  {% set advance_count = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_count") %}
                  {% if ((current_count == 0 or current_count == None) and (advance_count == 0 or advance_count == None)) %}
                  **<font color=#c5e566>Keine Warnungen</font>**
                  {% else %}
                    {% for i in range(current_count) %}
                      {% set headline = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_headline") %}
                      {% set description = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_description") %}
                      {% set level = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_level") %}
                      {% set time_start = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_start") | as_timestamp %}
                      {% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
                      {% set time_end = state_attr("sensor.dwd_weather_warnings_108119000_aktuelle_warnstufe", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
                      {% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
            **<font color={{ level_colors[level] }}>{{ 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 %}
                    {% if ((current_count != 0) and (advance_count != 0)) %}{% endif %}
                    {% for i in range(advance_count) %}
                      {% set headline = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_" ~ loop.index ~ "_headline") %}
                      {% set description = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_" ~ loop.index ~ "_description") %}
                      {% set level = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_" ~ loop.index ~ "_level") %}
                      {% set time_start = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_" ~ loop.index ~ "_start") | as_timestamp%}
                      {% set weekday_start = time_start | timestamp_custom("%w", True) | int %}
                      {% set time_end = state_attr("sensor.dwd_weather_warnings_108119000_vorwarnstufe", "warning_" ~ loop.index ~ "_end") | as_timestamp %}
                      {% set weekday_end = time_end | timestamp_custom("%w", True) | int %}
            **<font color={{ level_colors[level] }}>{{ 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 %} 
          title: Wetterwarnung

Vielen Dank schon einmal!

LG
fl0wing