The following code works (i.e. the badge is not shown) if the state is “Vert”. It doesn’t if the state is “vert” (or VERT or vErT, etc.).
type: custom:mushroom-template-badge
content: |-
{% if states('sensor.63_weather_alert') | lower == "vert" %}
Niveau d'alerte vert
{% else %}
Alerte {{states(entity) | lower }}
{% endif %}
icon: |-
{% if is_state(entity, "Unknown") %}
mdi:cloud-question-outline
{% else %}
mdi:weather-cloudy-alert
{% endif %}
color: |-
{% if states('sensor.63_weather_alert') | lower == "vert" %}
green
{% elif states('sensor.63_weather_alert') | lower == "jaune" %}
yellow
{% elif states('sensor.63_weather_alert') | lower == "orange" %}
orange
{% elif states('sensor.63_weather_alert') | lower == "rouge" %}
red
{% else %}
grey
{% endif %}
entity: sensor.63_weather_alert
label: Météo
tap_action:
action: navigate
navigation_path: /dashboard-global/meteo
visibility:
- condition: state
entity: sensor.63_weather_alert
state_not: Vert
You may have noticed I made the color and content dynamic and case insensitive with if states('sensor.63_weather_alert') | lower
. How would you achieve this with the condition (and why isn’t it the default behavior?)?