Change senor value 0 or 1 to OK or Refill

I have a sensor for a smal water tank (sensor.akab_out_of_water) with value 0 when it’s OK and value 1 when it’s empty.

I would like to change that in my Lovelace , instead of 0 to be OK and instead of 1 to be Refill.

So can anyone be kind and guide me how I can do these changes so that I don’t see 0 or 1.

Try something like this

type: markdown
content: >
    {% if (states('sensor.akab_out_of_water') == '1') %}
        <font color="red">Refill</font>
    {% elif (states('sensor.akab_out_of_water') == '0') %}
        <font color="red">OK</font>
    {% else %}
        <font color="orange">Unknown</font>
    {% endif %}
1 Like

If you’re comfortable with using custom cards, then Thomas Lovén’s template entity row should do what you’re looking for.

I solved it with some help from the code @WallyR posted

#Akab Water Tank
  - sensor:
      - name: "Akab Water Tank"
        state: >
          {% if is_state('sensor.akab_out_of_water', '1') %}
          {% elif is_state('sensor.akab_out_of_water', '0') %}
          {% else %}
          {% endif %}

You just made another sensor derived from the original one.
It works too.

My solution was just to change the view on the lovelace card.

Yes, I couldn’t get your card example to work with my cards and config. So I modified your and created a sensor template.

Once again thank you

You seem to have found a way to move forward.
Happy coding! :slightly_smiling_face: