Wait_template in blueprint

I have a blueprint with a variable and I would like to wait until all of them are in the OFF state in the action.

variables:
  motion_trigger: !input motion_trigger

In Action: If I put a sensor in it works but there are many and they can change so I need to use the variable.

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ is_state('binary_sensor.motion_sensor_front_door', 'off') }}"

If I try any of these they don’t work.

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ state('motion_trigger', 'off') }}"

#or

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ states('motion_trigger', 'off') }}"

#or

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ state[motion_trigger] == 'off' }}"

#or

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ states[motion_trigger] == 'off' }}"

#or this one, I thought it would work

  - alias: "Wait until all binary sensors are off"
    wait_template: "{{ states[motion_trigger].state == 'off' }}"

could anyone help?

Here is a Template someone helped me with, tried & true.
Easy to follow and you could modify it easily

condition:
  - condition: template
    value_template: >
      {{ states('binary_sensor.driveway_1_motion')|bool(0) +
      states('binary_sensor.driveway_2_motion')|bool(0) +
      states('binary_sensor.driveway_3_motion')|bool(0) > 1 }}

Hope it helps.

1 Like

You can create a group with the multiple sensors and monitor that group if that was just one sensor, so your life will be much easier.
Go to Settings > Devices & Services > Helpers, click to add a helper, select Groups, and then select binary sensors. You will be able to add the motion sensors you want to monitor together in a new entity.
With the group if any sensor triggers, the new group entity will be on, and will stay on until all sensors stops detecting movement. And you can even change this behave of the group if you want.

This solution from @007DJ will probably work as well and will be better in case you want to distribute your blueprint, so you don’t have to give instructions on how to create the groups. In this case just note you would like to end with <1 instead of >1 as you want all sensors to be off.

Hi, @007DJ thanks for the info I will keep that in mind.

@EdwardTFN Yea that’s what I ended up doing in my blueprint, It then created another problem that I did resolve and fix. Thanks for helping.

1 Like