How to change state color for template sensor

hello,

i created badge for an template sensor. this sensor has three possible states good, ALARM, Sensor Error!.

i tryed to change color in the badge according state, but this does not work, it is alwas red, as color seems to be defined by any HA default states only and mine are not off, closed etc…?

how could i get e.g. a RED color for ALARM state, any other color for state Sensor Error!? and all others states default color (blue)

here my template sensor

## FLOODLEVEL template Sensor Waschkueche AbflussALARM START
      floodalarm_inhouse:
        #unit_of_measurement: mm
        value_template: >-
            {% if is_state("binary_sensor.aqara_ws_103_water_leak", "off") %}
              good
            {% elif is_state("binary_sensor.aqara_ws_103_water_leak", "on") %}
              ALARM
            {% else %}
              Sensor Error!
            {% endif %}
## FLOODLEVEL template Sensor Waschkueche AbflussALARM END

thanx in advance
br
Frank

Your possible solutions could be either using a custom card creating a similar badge or card/mod (ask in the main card/mod thread or find there ready examples)

thanx @Ildar_Gabdullin ,
i thougth this would be more simpler?

where is the main card/mod thread?

br
Frank

Try both variants.
Cannot give you a link from a mobile.
Try searching it in Share your projects.

1 Like

Link is here

2 Likes

Means - some mushroom badge card (cannot tell exactly which one, not using them)