Two input_text passed to an automation


I would like to pass two input_text to one automation, lovelace card looks as follows:
I would like to add some action button and when I type both texts and press buttton then would like to trigger automation and pass to it both input_text fields.
Could you advise?


Hi, what is the exact actions you are thinking off? Normally you get the text by calling the state of the input_text

I would like to pass those two texts from input_text into shell command as an arguments.

Add a script to the bottom of the card. It will appear with an execute button, press the button, run the script.

The script being to call your shell command.

What you mean add script to the bottom of card?
I cannot add script as an entity in entity list.

You cannot “pass” anything to an automation. An automation does not receive variables it is designed to trigger when certain events occur.

You can pass variables to a script. Documentation reference: Passing variables to scripts

If these are the only two input_texts that will ever be used by the script, then you don’t even need to pass their values as variables. The script can directly reference each input_text’s value.

Here’s an example of what I mean:

I have two input_texts:


I created the following script, called script.combine_texts, which simply combines the values of the two input texts and displays them as a persistent_notification.

  alias: Combine Texts
  - service: persistent_notification.create
      title: Combined Message
      message: "{{ states('input_text.text_1') }} {{ states('input_text.text_2') }}"
  mode: single

I created an Entities card containing the two input_texts and the script. Here is how it appears after I entered some text in the input_texts:

Screenshot from 2021-02-21 09-21-02

When I click EXECUTE, the script is executed and it produces the following persistent_notification. The important point here is that it directly references the values of the two input_texts.

Screenshot from 2021-02-21 09-20-50

That was the simplest example and it can be more sophisticated. For example, you may wish to use a button to execute the script.


Thank you, will test this solution, looks good.

1 Like