Hi, i have a custom mushroom chips card, and i want to cahnge the color of the battery icon based on battery percentage.
My following code doesnt work, it shows the right color, but no percentage
can anyone help?
type: custom:mushroom-chips-card
chips:
- type: entity
entity: sensor.lights_on_count
double_tap_action:
action: none
use_entity_picture: false
icon_color: amber
tap_action:
action: none
hold_action:
action: none
- type: entity
entity: sensor.windows_on_count
double_tap_action:
action: none
icon: mdi:window-open-variant
use_entity_picture: false
tap_action:
action: none
hold_action:
action: none
- type: template
entity: sensor.batterie_ladezustand
icon: mdi:car-battery
use_entity_picture: false
tap_action:
action: none
hold_action:
action: none
value_template: '{{ states(''sensor.batterie_ladezustand'') }}'
icon_color: |
{% set battery_level = states('sensor.batterie_ladezustand')|int %}
{% if battery_level | int > 60 %}
green
{% elif battery_level | int > 20 %}
yellow
{% else %}
red
{% endif %}
- type: weather
entity: weather.forecast_home
show_conditions: false
show_temperature: true
alignment: center