Using multiple entity selector vibration sensors in the blueprint trigger?

I am trying to use a blueprint for vibration sensors. I found an existing blyueporiont that allows a single vibration sensor. I am trying to modify it so I can use multiple vibration sensors, if any of the sensors go off, it triggers the automation.

This is what I currently have but it does not work. I think I need to break out the !input vibration_sensor because it is a list now instead of a single value.

blueprint:
  name: Appliance has finished shaking
  description:
    Do something when an appliance (like a washing machine or dishwasher)
    has finished as detected by a vibration sensor.
  domain: automation
  input:
    vibration_sensor:
      name: Vibration Sensor
      description:
        "Vibration sensor entity (e.g.  Aqara lumi.vibration.aq1 by LUMI
        vibration sensor). Needs to have device_class: vibration"
      selector:
        entity:
          domain:
            - binary_sensor
          device_class:
            - vibration
          multiple: true
    starting_hysteresis:
      name: Starting hysteresis
      description: Time duration the sensor has to stay on.
      default: 5
      selector:
        number:
          min: 1.0
          max: 60.0
          unit_of_measurement: min
          mode: slider
          step: 1.0
    finishing_hysteresis:
      name: Finishing hysteresis
      description: Time duration the sensor has to stay off.
      default: 5
      selector:
        number:
          min: 1.0
          max: 60.0
          unit_of_measurement: min
          mode: slider
          step: 1.0
    actions:
      name: Actions
      description: Actions (e.g. pushing a notification, TTS announcement, ...)
      selector:
        action: {}
  source_url: https://community.home-assistant.io/t/blue-print-to-work-with-aqara-vibration-sensor-for-automation-to-trigger-notification-or-other-action-when-dishwasher-or-washing-machine-is-done/282553
trigger:
  # need to break out list? like any(x for x in !input vibration_sensor) ?
  - platform: state
    entity_id: !input vibration_sensor
    to: "on"
    for:
      minutes: !input starting_hysteresis
condition: []
action:
  - wait_for_trigger:
      - platform: state
        entity_id: !input vibration_sensor
        to: "off"
        for:
          minutes: !input finishing_hysteresis
  - choose: []
    default: !input actions
mode: single
max_exceeded: silent

I have tried all sorts of stuff and cant get it to work.

blueprint:
  name: Vibration sensor with hysterisis - multi
  description:
    Do something when an appliance (like a washing machine or dishwasher)
    has finished as detected by a vibration sensor.
  domain: automation
  input:
    vibration_sensor:
      name: Vibration Sensor
      description: "Vibration sensor entity. Needs to have device_class: vibration"
      selector:
        entity:
          domain:
            - binary_sensor
          device_class:
            - vibration
          multiple: true
    starting_hysteresis:
      name: Starting hysteresis
      description: Time duration the sensor has to stay on.
      default: 5
      selector:
        number:
          min: 1.0
          max: 60.0
          unit_of_measurement: min
          mode: slider
          step: 1.0
    finishing_hysteresis:
      name: Finishing hysteresis
      description: Time duration the sensor has to stay off.
      default: 5
      selector:
        number:
          min: 1.0
          max: 60.0
          unit_of_measurement: min
          mode: slider
          step: 1.0
    actions:
      name: Actions
      description: Actions (e.g. pushing a notification, TTS announcement, ...)
      selector:
        action: {}

trigger_variables:
  vibration_sensor: !input "vibration_sensor"

trigger:
  - platform: template
    value_template: >
      {% if vibration_sensor is string %}
        {% set vibration_sensor = [vibration_sensor] %}
      {% endif %}
      {% for snsr in vibration_sensor %}
        {% if snsr == "on"%}
        true
        {%- break %}
        {%- endif %}
      {%- endfor %}
    for:
      minutes: !input starting_hysteresis

condition: []

action:
  - wait_for_trigger:
      - platform: template
        # reverse the logic
        value_template: >
          {% if vibration_sensor is string %}
            {% set vibration_sensor = [vibration_sensor] %}
          {% endif %}
          {% for snsr in vibration_sensor %}
            {% if snsr != "on"%}
            true
            {%- break %}
            {%- endif %}
          {%- endfor %}
        for:
          minutes: !input finishing_hysteresis
  - choose: []
    default: !input actions
mode: single
max_exceeded: silent

Hi baudneo,

I don’t know… To me this:

looks a lot like this:
Automation Trigger - Home Assistant.

  trigger:
    - platform: state
      entity_id:
        - device_tracker.paulus
        - device_tracker.anne_therese
      # Optional
      from: "not_home"
      # Optional
      to: "home"
      # If given, will trigger when the condition has been true for X time; you can also use days and milliseconds.
      for:
        hours: 0
        minutes: 1
        seconds: 0

What does the trace say or what is the error?

The trace never runs because the data is never seen by the automation, so there is no error and the automation from the blueprint is never triggered. I’ve read all sorts of docs and was just trying everything.

It seems weird that they allow multiple entities but you can’t access any of the entites, so I’m assuming I’m missing something blatantly obvious.

I solved my problem by using automations, but it would be nice if they gave an example of how we access multiple entities in a template trigger from a blueprint.

Edit: at first I simply tried what that example shows, just add multiple: true and leave everything else the same, no bueno. Then I started to try and access each of the entities in the list after searching this forum and seeing people say to assign the data to a variable so that the template trigger can iterate over it using a for loop.

Ok, that a start, it never triggers. Remove the to: and the for: and see if it will trigger then.
If that don’t trigger list the actual entity names in there.
If you don’t get a trigger then, force a state change on one of the entities.
If no trigger then you will need to do a template trigger and mash that logic in a template.

Basically what I’m saying is break chunks out of the problem and eliminate that, then when you see the result change, you know the thing you eliminated it at least one of the problems, then you can work the actual problem and not tale a shotgun to the whole thing.

Oh sorry, when I was testing I removed the to: and from: conditionals.

I’ve already tested the template in the developer tools and it triggers no problem because it can read the entities themselves.

Let me hop on desktop here so I can show what I’ve been trying to cook up, I’ll edit this comment shortly. Thank you.

Edit: I ended up deleting the dev tools templates because I moved on and just wrote my own automation, sans blueprint. I may revisit this in the future, I don’t necessarily need to make this blueprint, I was just trying to contribute back for others that may have a need for multiple input vibration sensors.

I do appreciate the response and help!

{% if (states('binary_sensor.dryer_on_multi') == 'on') %}
true
{%- else %}
false
{%- endif %}

Your template is asking if any of the entity IDs are “on”… which will never be true. You’re missing the step to get their state. You can eliminate the loop by using built-in filters:

Corrected template
  - platform: template
    value_template: >
      {% set vibration_sensor = [vibration_sensor] if vibration_sensor is string else vibration_sensor %}
      {{ vibration_sensor | select('is_state', 'on') | list | count > 0 }}
    for:
      minutes: !input starting_hysteresis

However, I agree with @Sir_Goodenough that there doesn’t seem to be any reason to use the template for the main trigger…

...

trigger:
  - platform: state
    entity_id: !input vibration_sensor
    to: "on"
    from: "off"
    for:
      minutes: !input starting_hysteresis
condition: []
action:
  - alias: Wait until the entity that triggered the automation has been "off" for a specified time
    wait_for_trigger:
      - platform: template
        value_template: >
          {{ is_state(trigger.entity_id, 'off') }}
        for:
          minutes: !input finishing_hysteresis
  - choose: []
    default: !input actions
mode: single
max_exceeded: silent

If you wanted to wait for all the vibration sensors to be off instead of just the one that triggered the automation you could use a variation of the template from earlier:

  - alias: Wait until all the vibrations sensors have turned "off" and stayed "off" for a specified time
    wait_for_trigger:
      - platform: template
        value_template: >
          {% set vibration_sensor = [vibration_sensor] if vibration_sensor is string else vibration_sensor %}
          {{ vibration_sensor | select('is_state', 'on') | list | count == 0 }}
        for:
          minutes: !input starting_hysteresis