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