Hi, maybe somebody can help me.
- type: custom:mushroom-chips-card
chips:
- type: template
entity: sensor.telefoon_van_elwin_battery_level
icon: >
{% set battery_level =
states('sensor.telefoon_van_elwin_battery_level') | default('0') | int
%} {% if is_state('binary_sensor.telefoon_van_elwin_is_charging',
'on') %}
mdi:battery-charging
{% else %}
{% if battery_level >= 90 %}
mdi:battery
{% elif battery_level >= 80 %}
mdi:battery-80
{% elif battery_level >= 70 %}
mdi:battery-70
{% elif battery_level >= 60 %}
mdi:battery-60
{% elif battery_level >= 50 %}
mdi:battery-50
{% elif battery_level >= 40 %}
mdi:battery-40
{% elif battery_level >= 30 %}
mdi:battery-30
{% elif battery_level >= 20 %}
mdi:battery-20
{% elif battery_level >= 10 %}
mdi:battery-10
{% else %}
mdi:battery-alert
{% endif %}
{% endif %}
icon_color: >
{% set battery_level =
states('sensor.telefoon_van_elwin_battery_level') | default('0') | int
%} {% if battery_level >= 30 %}
green
{% elif battery_level >= 10 %}
amber
{% else %}
red
{% endif %}
card_mod:
style: |
ha-card {
background: transparent !important;
box-shadow: none !important;
border-width: 0 !important;
padding-left: 35px;
margin-top: -5px;
}
.content {
{% if is_state('binary_sensor.telefoon_van_elwin_is_charging', 'on') %}
animation: charge 5s linear infinite;
{% endif %}
}
@keyframes charge {
0%, 80% { clip-path: inset(0 0 0 0); }
10% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 84%, 34% 84%, 34% 100%, 100% 100%, 100% 0%); }
20% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 74%, 34% 74%, 34% 100%, 100% 100%, 100% 0%); }
30% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 64%, 34% 64%, 34% 100%, 100% 100%, 100% 0%); }
40% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 54%, 34% 54%, 34% 100%, 100% 100%, 100% 0%); }
50% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 44%, 34% 44%, 34% 100%, 100% 100%, 100% 0%); }
60% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 34%, 34% 34%, 34% 100%, 100% 100%, 100% 0%); }
70% { clip-path: polygon(0% 0%, 0% 100%, 34% 100%, 34% 24%, 67% 24%, 67% 24%, 34% 24%, 34% 100%, 100% 100%, 100% 0%); }
}
its working, but the only ugly thing is: After the animation is done, it will dissapear for like a second. This is not the case with a template card using “ha-state-icon”
Somebody knows how to fix this?