Template error in MQTT light

Quick question, what’s wrong with the value template in the below. I try to define an MQTT light that doesn’t get ON or OFF states only brightness level. So use a template to turn the state into an on or off depending on brightness value. OFF if it’s 0 ON otherwise
The error message is found character ‘%’ that cannot start any token

  - platform: mqtt
    name: "Test light"
    state_topic: "test/light/brightness"
    state_value_template: { {% if value == 0 %} OFF {% else %} ON {% endif %} }
    command_topic: "test/light/switch"
    brightness_state_topic: 'test/light/brightness'
    brightness_command_topic: 'test/light/brightness/set'
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false

try:

state_value_template: '{% if value == 0 %} OFF {% else %} ON {% endif %}'