Hello,
this is my script for my chips card on top of my dashboard. I would like the color of the battery icon to change, based on its sensor’s state:
- type: custom:mushroom-chips-card
chips:
- type: entity
entity: sensor.tabingresso_battery_level
double_tap_action:
action: none
use_entity_picture: false
hold_action:
action: none
icon_color: >-
{% set level = state('sensor.tabingresso_battery_level') %}
{% if level >= 7 %}
green
{% else %}
red
{% endif %}
…but con is always white:
This below code works if used for a custom:mushroom-template-card (still not works for chips card), but only if I tell the script to look for a specific value (29):
{% if is_state('sensor.tabingresso_battery_level', '29') %}
yellow
{% endif %}
The function is states() not state()… but there are other changes you need to make as well.
States are always strings, so you need to convert them to a integer or float before using mathematical operations or comparisons.
Optionally, Mushroom allows use of a variable entity so you don’t need to use the whole entity_id