[2024.8.0] MQTT payload_template depreciated

I understand you saying the solution is to change payload_template to payload, but it sounds like this only works when the MQTT publish service call (or action) is called from within an automation or script. If the MQTT publish is called from a button push, for example, the template is not processed and the template string itself is published. In this example, I am calling from a button:

  - name: Set first temp
    type: button
    tap_action:
      action: call-service
      service: mqtt.publish
      service_data:
        payload: {{ states('input_number.first_warmup_temp')  }}
        topic: home/thermostat/first/targetTemp/set

With ‘payload_template’, the string “69” is published
With ‘payload’, this string “{{ states(‘input_number.1st_warmup_temp’) }}” is published

The frontend has never supported templates in tap action service data. Payload_template or not.

1 Like

That’s never worked. The solution has always been to have the button call a script.

Payload_template has been supported for about 2 years and still works.

Simply changing payload_template to payload results in the code being passed via MQTT not the values as others have pointed out.

payload_template: >-
{“state”:“ON”,“brightness”:{{ states(“input_number.brightness_level”) | int
}}}

Why disable something that is working with an alternative that fails?

Scripts don’t appear to help.

What is the solution other than keeping what works?

post your full code, payload works fine with or without templates. What you’re showing above isn’t formated. We can’t tell if it’s correct.