Make a visibility condition case insensitive

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?)?

I’d make a template entity that lowers the result and use that instead.

{{ states('sensor.63_weather_alert') | lower }}

Because everyone has a different use case and a different state to find. Some people may want to find exact wording.

I’m just a noob but I hate creating entities for a front-end issue, it adds to the clutter (in my mind).

Have you ever encountered a case in which “State” should be True and “state” False? Not trying to be a jerk: I’m curious to know if people have a use case for case-sensitive if statements on states.

Unless you meant doing this inside the badge’s yaml? But I couldn’t make it work

Anyone has a solution that doesn’t require creating an entity?

Yes, write out all the combinations in your not_state