Blueprint multiple selector - how to use?

The documentation for the new multiple attribute of a selector in blueprints is missing how to use the list of entities in the action/condition part.

Obviously everything used to be working for only one device, but how does a state trigger or a condition work for a list of entities? Particular in this area of my automation/blueprint:

trigger:
- platform: state
  entity_id: !input 'window_entities'
  to: 'on'
action:
[...]
- wait_for_trigger:
  - platform: state
    entity_id: !input 'window_entities'
    to: 'off'
  continue_on_timeout: false

I haven’t really tested it yet, but does this even work? And will it trigger when one of the list members switches to “on” or only when all of them switch to “on”? How do I achieve either version?

bumb. I still have no clue how to work with a list in the action part?

I found a solution/workaround for my specific use-case:

variables:
  climate_target: !input 'climate_entity'
  windows: !input 'window_entity'
trigger:
- platform: state
  entity_id: !input 'window_entity'
  to: 'on'
action:
[...]
- wait_template: >
        {% set closed = namespace(bool=true) %}
        {% for state in states.binary_sensor%}
            {% if state.entity_id in windows %}
                {% if state.state == "on" %}
                 {% set closed.bool = false %}
                {% endif %}
            {% endif %}
        {% endfor %}
        {{closed.bool}}
  continue_on_timeout: false

This enables my thermostats to recognise whenever any window is open, but only switches back to normal mode when alle the windows are closed again.

1 Like

Did you have any luck using a state condition with a “match: any” clause?

No, I haven’t. But as far as I remember that was not the issue. The issue is how to pass a list of entities that were defined by the user creating the automation with the blueprint into the condition/wait_for_trigger part. Do you have any suggestion how to change the action part to make use of match: any?

I’m looking for the same, did you have any luck?

I would like to match any from a multiple input - not all of them

A selector with multiple set to true defaults to any for a true evaluation.

So if used in a condition, it will evaluate to true if just one of the entries in the selector is true. This means a false condition requires all entries to be false.

To have the condition use all to be true instead of any requires some more work.

Here’s how I did it. In my case I had multiple (boolean) sleep triggers (stored in variable sleep_triggers) that ALL had to evaluate to true (on) to trigger an action.

- condition: template
  value_template: "{{ expand(sleep_triggers) | selectattr('state', 'eq', 'on') | list | count == 0 }}"

What this means is I expand the list of sleep_triggers and then check if the amount that have their state set to ‘off’ is zero. This way I know they’re all set to ‘on’, no matter how many entries there are.