Use of Topic_Template in MQTT results in error

I’m trying to set the topic of an MQTT message to publish with a template. This however seems not to work properly. At least not as I expect.

I have an input_text which is set to the specific topic somewhere else in my automation. Then I want to set the MQTT topic to the text in that input_text with: "{{states("input_text.awtrix_device")}}"

This however seems not to work as I get an error saying the result of the template is None. Which is not true when I test it in Template within developer tools:

This works when testing in the Services of Developer tools:

service: mqtt.publish
data:
  topic_template: "Desktop_Awtrix/notify"
  payload: "test"

This does not:

service: mqtt.publish
data:
  topic_template: "{{states("input_text.awtrix_device")}}"
  payload: "test"

Can someone point me in the right direction to solve this? Where is my error?

You cannot have double-quotes inside double-quotes

  topic_template: '{{states("input_text.awtrix_device")}}'
1 Like

Ah! Stupid me. I should have seen that.