Blueprint with !input text in mqtt json payload

Hello there,

I’m trying to write my first Blueprint that simply sends some user entered value onto a Mqtt topic. But struggling to work out how to send the !input value through into the json payload. Have tried both introducing a variable and referencing the !input value directly. Am I missing some magic escape sequence or doing something utterly wrong here?

blueprint:
  name: Hello MQTT BluePrint
  input:
    display_text:
      name: Display Text
variables:
  display_text: !input display_text
action:
  - service: mqtt.publish
    data:
      topic: notify
      payload: |-
        {
          "text": {{ display_text }}
        }

Also tried:

       {
          "text": {{ !input display_text }}
        }

All with and without the curly braces around the variable value.

Any tips, much appreciated!

Thanks

I do this a lot in this BP and other of my BP’s…

Check that out and if you have questions, drop a reply here.

Thanks @Sir_Goodenough for this - much appreciated, after taking a look at your repo - I’ve now got this working :slight_smile:

For my future self or others, this is what I needed to change it to:

blueprint:
  name: Hello MQTT BluePrint
  input:
    display_text:
      name: Display Text
variables:
  display_text: !input display_text
action:
  - service: mqtt.publish
    data:
      topic: notify
      payload: >
        {
          "text": "{{ display_text }}"
        }
1 Like