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' }}"
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.