You need
Template for binary sensors
please pay attention to <x>
; replace it with 1, 2, 3
replace <the_city>
according to your location
{% if state_attr('sensor.dwd_warnungen_<the_city>_current_warning_level', "warning_count") != None %}
{{ state_attr('sensor.dwd_warnungen_<the_city>_current_warning_level', "warning_count") >= <x> }}
{% else %}
0
{% endif %}
The Code Snippets
replace <the_city>
according to your location
decluttering card
wetter_warnung_template:
card:
type: conditional
conditions:
- entity: binary_sensor.dwd_warnungen_<the_city>_[[time]]_[[warning]]
state: 'on'
card:
type: custom:mushroom-template-card
primary: >-
{% if
states('binary_sensor.dwd_warnungen_<the_city>_[[time]]_[[warning]]')
== 'on' %} {% set dwd_sensor =
"sensor.dwd_warnungen_<the_city>_[[time]]_warning_level" %}
{% set days = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"] %}
{% set headline = state_attr(dwd_sensor, ("[[warning]]")).event %}
{% set time_start = state_attr(dwd_sensor, ("[[warning]]_start")) %}
{% set time_end = state_attr(dwd_sensor, ("[[warning]]_end")) %}
{% set ts = as_timestamp(time_start) | timestamp_local %}
{% set wd_start = as_timestamp(ts) | timestamp_custom("%w") | int %}
{% set t_start = as_timestamp(ts) | timestamp_custom("%-H:%M") %}
{% set day_start = days[wd_start] %}
{% set ts = as_timestamp(time_end) | timestamp_local %}
{% set wd_end = as_timestamp(ts) | timestamp_custom("%w") | int %}
{% set t_end = as_timestamp(ts) | timestamp_custom("%-H:%M") %}
{% if (wd_end == wd_start) %}
{% set day_end = "" %}
{% else %}
{% set day_end = days[wd_end] +" " %}
{% endif %}
{{headline}}: {{day_start}} {{t_start}} - {{day_end}}{{t_end}} {%
endif %}
secondary: >-
{% if
states('binary_sensor.dwd_warnungen_<the_city>_[[time]]_[[warning]]')
== 'on' %} {% set dwd_sensor =
"sensor.dwd_warnungen_<the_city>_[[time]]_warning_level" %}
{% set description = state_attr(dwd_sensor,
("[[warning]]")).description %}
{% if None == state_attr(dwd_sensor, ("[[warning]]")).instruction %}
{% set instruction = '' %}
{% else %}
{% set instruction = state_attr(dwd_sensor,
("[[warning]]")).instruction %}
{% endif %}{{description}}
{{instruction}} {% endif %}
icon: >-
{% if
states('binary_sensor.dwd_warnungen_<the_city>_[[time]]_[[warning]]')
== 'on' %} {% set dwd_sensor =
"sensor.dwd_warnungen_<the_city>_[[time]]_warning_level" %}
{% set type_to_img = {
11: "",
12: "",
13: "",
14: "",
15: "",
16: "",
22: "fas:temperature-arrow-down",
24: "fas:person-falling",
31: "fas:cloud-bolt",
33: "fas:cloud-bolt",
34: "fas:cloud-bolt",
36: "fas:cloud-bolt",
38: "fas:cloud-bolt",
40: "fas:cloud-bolt",
41: "fas:cloud-bolt",
42: "fas:cloud-bolt",
44: "fas:cloud-bolt",
45: "fas:cloud-bolt",
46: "fas:cloud-bolt",
48: "fas:cloud-bolt",
49: "fas:cloud-bolt",
51: "fas:wind",
52: "fas:wind",
53: "fas:wind",
54: "fas:wind",
55: "fas:wind",
56: "fas:wind",
57: "fas:wind",
58: "fas:wind",
59: "fas:smog",
61: "fas:cloud-showers-heavy",
62: "fas:cloud-showers-heavy",
63: "fas:cloud-showers-heavy",
64: "fas:cloud-showers-heavy",
65: "fas:cloud-showers-heavy",
66: "fas:cloud-showers-heavy",
70: "far:snowflake",
71: "far:snowflake",
72: "far:snowflake",
73: "far:snowflake",
74: "far:snowflake",
75: "far:snowflake",
76: "far:snowflake",
79: "",
82: "fas:temperature-arrow-down",
84: "fas:person-falling",
85: "fas:person-falling",
87: "fas:person-falling",
88: "fas:temperature-arrow-up",
89: "fas:temperature-arrow-up",
90: "fas:cloud-bolt",
91: "fas:cloud-bolt",
92: "fas:cloud-bolt",
93: "fas:cloud-bolt",
95: "fas:cloud-bolt",
96: "fas:cloud-bolt",
98: "",
99: "",
246: "mdi:weather-sunny-alert",
247: "mdi:sun-thermometer-outline",
248: "mdi:sun-thermometer-outline"}
%}
{% set img = type_to_img[state_attr(dwd_sensor,
("[[warning]]")).event_code] %}
{{img}} {% endif %}
icon_color: >-
{% if
states('binary_sensor.dwd_warnungen_<the_city>_[[time]]_[[warning]]')
== 'on' %} {% set dwd_sensor =
"sensor.dwd_warnungen_<the_city>_[[time]]_warning_level" %}
{% set type_to_color = {
11: "",
12: "",
13: "",
14: "",
15: "",
16: "",
22: "amber",
24: "amber",
31: "amber",
33: "orange",
34: "orange",
36: "orange",
38: "orange",
40: "red",
41: "pink",
42: "red",
44: "red",
45: "pink",
46: "red",
48: "red",
49: "pink",
51: "amber",
52: "orange",
53: "orange",
54: "red",
55: "red",
56: "pink",
57: "amber",
58: "orange",
59: "amber",
61: "orange",
62: "red",
63: "orange",
64: "red",
65: "pink",
66: "pink",
70: "amber",
71: "orange",
72: "red",
73: "pink",
74: "orange",
75: "red",
76: "pink",
79: "",
82: "orange",
84: "amber",
85: "orange",
87: "red",
88: "orange",
89: "red",
90: "amber",
91: "orange",
92: "red",
93: "pink",
95: "pink",
96: "pink",
98: "",
99: "",
246: "pink",
247: "pink",
248: "purple"}
%}
{% set color = type_to_color[state_attr(dwd_sensor,
("[[warning]]")).event_code] %}
{{color}} {% endif %}
multiline_secondary: true
fill_container: false
layout: horizontal
tap_action:
action: none
hold_action:
action: none
double_tap_action:
action: none
Cards in Dashboard
** Heading
** max 3 current warnings
** max 3 advanced warnings
- type: conditional
conditions:
- condition: state
entity: sensor.dwd_warnungen_<the_city>_summe
state_not: '0.0'
card:
type: custom:mushroom-title-card
title: ā Wetterwarnung!
subtitle: <The City>
title_tap_action:
action: none
subtitle_tap_action:
action: none
- type: custom:decluttering-card
template: wetter_warnung_template
variables:
- warning: warning_1
- time: current
- type: custom:decluttering-card
template: wetter_warnung_template
variables:
- warning: warning_2
- time: current
- type: custom:decluttering-card
template: wetter_warnung_template
variables:
- warning: warning_3
- time: current
- type: custom:decluttering-card
template: wetter_warnung_template
variables:
- warning: warning_1
- time: advanced
If someone has an idea how to
- colorize the icon in the heading according to the severity of the most serious
- place the weather icon at the top instead of centered
please let me know