MQTT switch help with value template

I’m new to MQTT to I just want to preface this I’m probably overlooking something minor, but here goes.
I’ve created a switch using openMQTT. It’s using the RF2 library to control a smart socket in my home. When I click the switch button in the HA interface the light actually turns on so the commands are sending successfully. However, immediately after pressing the button, it returns itself to the ‘off state’. The light keeps burning however, so I think I possibly did not configure the state_topic / value template correct.

This is my button:

- platform: mqtt
  name: Garden light14
  state_topic: "home/OpenMQTTGateway/RF2toMQTT"
  command_topic: "home/OpenMQTTGateway/commands/MQTTtoRF2"
  payload_on: "{unit:4,groupBit:0,period:229,address:32057462,switchType:1}"
  payload_off: "{unit:4,groupBit:0,period:229,address:32057462,switchType:0}"
  value_template: >- 
      {% if value_json.switchType == '1' %}
      {% else %}
      {% endif %}
  qos: "0"
  retain: true

The ‘state_topic’ is definitely correct, when I subscribe to ‘home/OpenMQTTGateway/RF2toMQTT’ in my MQTT server I get the following messages:

    "unit": 4,
    "groupBit": 0,
    "period": 229,
    "address": 32057462,
    "switchType": 0

Another thing I realized is that this is the first of multiple switches, so I’ll probably need to incorporate the address into the value template too?

If anyone can help me on my way it’s much appreciated.

try changing the valut template to this:

value_template: >- 
  {% if value_json.switchType == 1 %}
  {% else %}
  {% endif %}