I’m still trying to wrap my head around templating so please excuse my ignorance
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?