Change how battery status is displayed

I have a rtl433 listening to my weather station. Data is sent to my mqtt broker, and looks like this:

  {
    "time": "2025-05-18 21:45:35",
    "model": "Vevor-7in1",
    "id": 11564,
    "channel": 0,
    "battery_ok": 1,
    "temperature_C": 16.9,
    "humidity": 55,
    "wind_avg_km_h": 0,
    "wind_max_km_h": 0,
    "wind_dir_deg": 298,
    "rain_mm": 40.775,
    "uv": 0,
    "light_lux": 63,
    "mic": "CHECKSUM",
    "mod": "FSK",
    "freq1": 868.38867,
    "freq2": 868.23021,
    "rssi": -0.108707,
    "snr": 26.47247,
    "noise": -26.5812
  }

As you can see, the battery status is transmitted as “battery_ok”: 1.
No percentage, just 1.

The yaml file I’m using to get the status on the dashboard is this:

  - name: "Weerstation batterij"
    unique_id: "weather_battery"
    force_update: true
    payload_on: 1
    payload_off: 0
    state_topic: "rtl_433/Vevor-7in1/11564"
    value_template: "{{ value_json.battery_ok }}"

However, this is shown as
Weerstation batterij On

I believe it would be nicer to show the status as OK as long as the status returned equals 1, and maybe something like Weak when the status returned equals 0.

Is this possible in any way ?

- name: "Weerstation batterij"
    unique_id: "weather_battery"
    force_update: true
    payload_on: 1
    payload_off: 0
    state_topic: "rtl_433/Vevor-7in1/11564"
    value_template: >
    {% if value_json.battery_ok == 1 %}
      OK
    {% else %}
      LOW
    {% endif %}

You can try this in the template editor under /developer-tools/template :wink:

image

Thanks for answering.
I tried your suggestion, and yes, in the template editor it works perfectly.
However, in real life, the entity remains Unknown, and I cannot figure out why.

Checking all yaml files reveals no errors.
Even tried state: > instead of value_template: >. That did make a change: the value is now displayed as Unavailable

And restarted HA after every change, but no cigar.

Any suggestions, please ?