core: Error when return a json as payload_template in automation actions

The problem

 action:
    service: mqtt.publish
    data_template:
      topic: "topic/test"
      payload_template: >
        {% set payload = {'value1': 'test', 'value2': 'test' } %}
        {{ payload|to_json }}
      qos: 0
      retain: true

Environment

  • Home Assistant Core release with the issue: 0.117.0b1
  • Last working Home Assistant Core release (if known): 0.116

Traceback/Error logs

Error executing script. Invalid data for call_service at pos 1: value should be a string for dictionary value @ data['payload_template']

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 20 (12 by maintainers)

Most upvoted comments

Alright, Paulus and I are going to crack this one today. We had a talk this morning on the approach and made a couple of tasks we are going to complete today.