Cannot publish temperature via mqtt template

Hi,
I cannot publish via mqtt the following data template:

      - service: mqtt.publish
        data:
          topic: "hasp/displ_entrance/command/p[3].b[9].txt"
          payload_template: '" {{ state_attr("sensor.livingroom_average_temerpature", "mean") | float | round(0) }}°"'

Even though in the developer tools the temperature is correct.

count_sensors: 2
max_value: 23.8
max_entity_id: sensor.multisensor_entrance_air_temperature
mean: 23.6
median: 23.6
min_value: 23.5
min_entity_id: sensor.multisensor_livingroom_air_temperature
last: 23.5
last_entity_id: sensor.multisensor_livingroom_air_temperature
unit_of_measurement: °C
icon: mdi:calculator
friendly_name: Livingroom average temperature

What am I doing wrong?

Hi again.

Try this

payload_template: "{{ state_attr('sensor.livingroom_average_temerpature', 'mean') | float | round(0) }}"

Hi again @Spiro. I tried your suggestion but it didn’t work. Any other idea?

just checking your spelling of temperature. It may be correct in a different language

I’m dumb. Thanks for pointing it out.

No problem. Been caught out few times with the spelling myself. :nerd_face:

1 Like