No matching payload

I got an ESP module to detect door opening and closing and publish to MQTT on the HA server.

I was able to configure the MQTT binary_sensor and it nicely shows on Homekit as Contact Sensor. If only I could nicely convert the MQTT payload to the sensor!! Im facing the No matching payload error as denoted below in the logs.

My doorsensor1.yaml

  - platform: mqtt
    state_topic: "maindoor"
    name: "main_door_sensor"
    qos: 0
    value_template: >
      {% if value_json.Door %}
        {{'ON'}}
      {% else %}
        {{'OFF'}}
      {% endif %}
    device_class: window

Error in the log file:

No matching payload found for entity: main_door_sensor with state topic: maindoor. Payload: {"time":"1493829297829","Door":False}, with value template Template("{% if value_json.Door %} {{'ON'}} {% else %} {{'OFF'}} {% endif %} ")
Error parsing value: 'value_json' is undefined (value: {"time":"1493829297829","Door":False}, template: {% if value_json.Door %} {{'ON'}} {% else %} {{'OFF'}} {% endif %} )

I was referring to this post while writing the template.

Any suggestions?

A binary_sensor expects ‘ON’ or ‘OFF’

 - platform: mqtt
   state_topic: "maindoor"
   name: "main_door_sensor"
   qos: 0
   value_template: >
     {% if value_json.Door %}
      'ON'
     {% else %}
       'OFF'
     {% endif %}
   device_class: window

Ok. I Changed the code to send just ON or OFF. Im still facing the same issue.

Error parsing value: 'value_json' is undefined (value: , template: {{ value_json.Status }})
Home Assistant has started!
No matching payload found for entity: main_door_sensor with state topic: maindoor. Payload: , with value template Template("{{ value_json.Status }}")
Home Assistant has started!

Here is the payload Im sending :

{"time":"Tue Jul 14 20:17:38 2020\n","Status":"OFF"}

However if I changed the payload to just this it works!! So Im guessing Im missing some JSON processing component/addon?
config:

  - platform: mqtt
    state_topic: "maindoor"
    name: "main_door_sensor"
    qos: 0
    value_template: "{{ value_json }}"
    device_class: door

Payload:

"ON"

I finally managed to solve this myself! With the new version, there is a lot of changes. Here is the solution:

  - platform: mqtt
    state_topic: "outdoor_metrics"
    name: "outdoor_temperature"
    unit_of_measurement: "°F"
    value_template: "{{ value_json.Temp }}"
    json_attributes_topic: "outdoor_metrics"
    json_attributes_template: "{{ value_json | tojson }}"
  - platform: mqtt
    state_topic: "outdoor_metrics"
    name: "outdoor_humidity"
    unit_of_measurement: "%"
    device_class: humidity
    value_template: "{{ value_json.Humidity }}"
    json_attributes_topic: "outdoor_metrics"
    json_attributes_template: "{{ value_json | tojson }}"

You see how tojson gets called? Thats the trick. Here is the payload for this.

{"Temp": "82.5","Humidity": "51.65%"}