A way to do a string-wise concatenation with inputs?

I’m looking for a way to concatenate string inputs from a blueprint, e.g, conceptually.

trigger:
  - platform: mqtt
    topic: !input base_topic + "/sensor/#"

I know that you can mostly use variables + template to do this, but the mqtt trigger doesn’t support templates, so I’m stuck.
I understand that blueprints do text-wise replaces, basically, so that should be possible even for triggers that need to be resolved before the automation is instantiated, like mqtt

Would there be a way to achieve this, currently?

Exactly.

The !input directive is handled by the YAML processor. It simply replaces !input whatever with a value and assigns it to a key.

    topic: !input whatever

It won’t do anything else and won’t accept any other information that might be present before or after the directive (the + "/sensor/#" in your example).

One way around this is to use variables.

  variables:
    raw: !input base_topic
  trigger:
  - platform: mqtt
    topic: "{{raw}}/sensor/#"

Except that won’t work because topic doesn’t accept a template and … we’re stuck.

1 Like

That forced me to use state as a trigger. So I ended up with

trigger:
  platform: state
  entity_id: !input your_device
action:
  - variables:
      command: "{{ trigger.to_state.attributes.action }}"