How to configure virtual sensor based from MQTT state

I’m still trying to wrap my head around templating so please excuse my ignorance :slight_smile:
I have the following MQTT device (screenshots attached).
The state of the MQTT device clearly shows that it contains a “local_temperature” attribute.


I wish to create a sensor that reads the local_temperature from the MQTT device and later use that sensor in a generic thermostat.

template:
  - sensor:
    - name: "Guest Bedroom TRV sensor"
      unique_id: sensor.guest_bedroom_trv
      unit_of_measurement: "°C"
      state: "{{ state_attr('climate.0x003c84fffe21f325', 'local_temperature') | float }}"

climate.0x003c84fffe21f325 is the ID of the device in HASS, though I’m getting:
TemplateError(‘ValueError: Template error: float got invalid input ‘None’ when rendering template ‘{{ state_attr(‘climate.0x003c84fffe21f325’, ‘local_temperature’) | float }}’ but no default was specified’) while processing template ‘Template("{{ state_attr(‘climate.0x003c84fffe21f325’, ‘local_temperature’) | float }}")’ for attribute ‘_attr_native_value’ in entity ‘sensor.guest_bedroom_trv_sensor’

I tried to play around in the Developer Tools → Templating and indeed it looks like my template is wrong - the attribute value of climate.0x003c84fffe21f325 appears to be null. I don’t understand what I’m doing wrong. Any ideas?

Found it…
So it looks like the attribute name is called ‘current_temperature’ instead of ‘local_temperature’. I’m not exactly sure what’s the reason MQTT shows the state json with ‘current_temperature’ but in HASS Developer Tools → States - the attribute is called ‘current_temperature’