Coloring new badges

Hello
I am trying this :

    badges:
      - type: entity
        entity: input_text.edf_couleur_utile
        name: EDF couleur
        display_type: complete
        color: |
          {% set state = states('input_text.edf_couleur_utile') %}  
          {% if state == 'BLEU' %}
            blue
          {% elif state == 'BLANC' %}
            yellow
          {% elif state == 'ROUGE' %}
            red
          {% else %}
            grey
          {% endif %}

Why can’t I replace for example blue by an expression giving blue ?

Thanks

my system

## System Information

version | core-2024.8.1
-- | --
installation_type | Home Assistant OS
dev | false
hassio | true
docker | true
user | root
virtualenv | false
python_version | 3.12.4
os_name | Linux
os_version | 6.6.31-haos-raspi
arch | aarch64
timezone | Europe/Paris
config_dir | /config

<details><summary>Home Assistant Community Store</summary>

GitHub API | ok
-- | --
GitHub Content | ok
GitHub Web | ok
GitHub API Calls Remaining | 5000
Installed Version | 1.34.0
Stage | running
Available Repositories | 1457
Downloaded Repositories | 5
HACS Data | ok

</details>

<details><summary>Home Assistant Cloud</summary>

logged_in | false
-- | --
can_reach_cert_server | ok
can_reach_cloud_auth | ok
can_reach_cloud | ok

</details>

<details><summary>Home Assistant Supervisor</summary>

host_os | Home Assistant OS 12.4
-- | --
update_channel | stable
supervisor_version | supervisor-2024.08.0
agent_version | 1.6.0
docker_version | 26.1.4
disk_total | 13.6 GB
disk_used | 6.0 GB
healthy | true
supported | true
host_connectivity | true
supervisor_connectivity | true
ntp_synchronized | true
virtualization | 
board | rpi4-64
supervisor_api | ok
version_api | ok
installed_addons | Mosquitto broker (6.4.1), Zigbee2MQTT (1.39.1-1), Advanced SSH & Web Terminal (18.0.0), File editor (5.8.0)

</details>

<details><summary>Dashboards</summary>

dashboards | 5
-- | --
resources | 4
views | 8
mode | storage

</details>

<details><summary>Recorder</summary>

oldest_recorder_run | 13 août 2024 à 15:46
-- | --
current_recorder_run | 13 août 2024 à 17:50
estimated_db_size | 138.58 MiB
database_engine | sqlite
database_version | 3.45.3

</details>

because templates are not supported, you cant just make up stuff that is not available…

there are many people looking for ways to customize the new badges.
Join here New badges and card-mod customisation to keep an eye on the matter

1 Like