Input.text as parameter in script

I’m trying to build a vacuum script that lets me clean multiple rooms based on what helper switches are on.
I managed to grab the buttons and put the respective numbers into a text helper. Nearly there.

The only problem I have is that it won’t accept my input as a parameter for the send command.

The moment I save the script with the template:
{{ states(“input_text.test_vacrooms”) }}

it turns it into “[object Object]”: null

action: vacuum.send_command
metadata: {}
data:
  command: app_segment_clean
  params:
    "[object Object]": null
target:
  device_id: 68f26d1ee5c34df4f120b8567d7ce499

Probably because you missed the quotes around the template, or didn’t make it a multiline text.

Here’s the exact copy of what I put in:

{{ states("input_text.test_vacrooms") }}

Didn’t miss quotes and from what I gather the text should be multiline:

action: input_text.set_value
metadata: {}
data:
  value: |
    {% if is_state('input_boolean.robert_gang', 'on') %}- 18{% endif%}
    {% if is_state('input_boolean.robert_living', 'on') %}- 20{% endif %} 
    {% if is_state('input_boolean.robert_essen', 'on') %}- 16{% endif %}
    {% if is_state('input_boolean.robert_kuche', 'on') %}- 19{% endif %}
target:
  entity_id: input_text.test_vacrooms

With the | and text on the next line is fine. But you cannot put a template on the same line, starting with {{ because that has a different meaning if not in a string. So you should put quotes around it all if it is on the same line:

    params: "{{ states('input_text.test_vacrooms') }}"

or

    params: |
      {{ states('input_text.test_vacrooms') }}

Thanks for the clarification!

It now keeps the value, so the code is valid.

However, it doesn’t work.
I’ve realized that I probably don’t need the helper and I could just paste all if is_state into the parameters directly, but it only works if I input actual numbers. :thinking:

If it needs to be a number, try this:

    params: "{{ states('input_text.test_vacrooms') | int(0) }}"

If I only pick one room it’s working fine now. But I can’t get it to work if I have multiple selected…

I tried sending integers only, one line and one entry per line. One room works with all options, but not with several. :unamused:

Given that I have 9 rooms thus over 500 possible combinations, I can’t just check all one by one.

As far as I can tell, this is not a template problem, but not knowing if the integration accepts multiple areas? Only if you know what to send (if possible at all), you can think about the template.

When you use multiple lines of if followed by endif, then the lines can be concatenated and you could end up with - 18- 20- 16- 19 as a result.
If one one of should exclude the result the. You need to use elif for the second and all following if lines.

Thanks for your help guys.
I’ve now managed to get it working by adding the values in an array/namespace and send that. Works as intended.