Passend zum Artikel (Blinkendes Badge-Icon) hier ein Beispiel für eine custom:bagde-card, die „normalerweise“ aus ist und nur bei einem gewissen Zustand „blinken“ soll.
Dieser Code unterscheidet sich im Prinzip nur ganz knapp von der „Ursprungsversion“.
Besondere Aufmerksamkeit schenken wir hier den Zeilen ab „display:…..“
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
type: custom:badge-card
badges:
- entity: binary_sensor.all_outdoor_lights
style: |
@keyframes blinker { 50% { opacity: 0; } }
:host {
--label-badge-text-color: black;
--label-badge-red: {% if states(config.entity)|int < 30 %}
red
{% elif states(config.entity)|int < 70 %}
yellow
{% elif states(config.entity)|int <= 100 %}
green
{% endif %};
--label-badge-background-color: {% if states(config.entity)|int < 30 %}
red
{% elif states(config.entity)|int < 70 %}
yellow
{% elif states(config.entity)|int <= 100 %}
green
{% endif %};
animation: blinker 1s linear infinite;
display:
{% if is_state('binary_sensor.all_outdoor_lights', 'on') %}
none;
{% endif %}
--ha-label-badge-label-color: black;
}