Last updated unavailable

Hi,

I have a couple of sensors configured on MQTT. Since the last update, I am no longer getting values for sensors based on these MQTT sensors, being the “last updated” values.

An MQTT sensor is configured as follows:

sensor:
  - state_topic: "application/14/device/xxxxxxx/event/up"
    name: School Battery
    unique_id: school voltage
    value_template: '{{ value_json["object"]["BAT_V"] }}'
    device_class: voltage
    unit_of_measurement: V

And the template sensors as follows:

- platform: template
  sensors:
    school_sensor_last_updated:
      friendly_name: "School last updated"
      value_template: >-
          {% set s = (now() - states.sensor.school_battery.last_changed).total_seconds() | round(0) %}
           {{ '%02d:%02d' % ((s/3600)|int, (s%3600)/60) }}
      unit_of_measurement: "Hours"
      unique_id: school_sensor_last_updated

The payload that is delivered over MQTT is as follows:


  "object": {
    "BAT_V": 3.054,
    "DOOR_OPEN_STATUS": 0,
    "DOOR_OPEN_TIMES": 225,
    "LAST_DOOR_OPEN_DURATION": 0,
    "MOD": "Door sensor"
  }
}

Any ideas as to what is going on here now? Is this possibly related to the new json format in templates?

Any help greatly appreciated