A wait step with no end is a fine way to end up with an automation that sits there for days. The timeout option is short, and the choice behind it is the one worth thinking about.
This is the shape, with a hallway light that waits for the motion sensor to go quiet:
actions:
- action: light.turn_on
target:
entity_id: light.hallway
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.hallway_motion
to: "off"
timeout:
minutes: 10
continue_on_timeout: true
- action: light.turn_off
target:
entity_id: light.hallway
The docs say timeout is the longest time to wait, and without it the automation waits until a trigger reacts. With continue_on_timeout: true the next steps run when the time is up. With false the automation or script stops there. Pick it on purpose: in my example I want the light off either way, so true fits.
After the wait you get wait.trigger, the data of the trigger that fired, or none if the timeout ended first. That lets you branch on how the wait ended. There is also wait.remaining, the seconds left of the timeout.
Two caveats from the docs. The wait only reacts to a change that happens after it starts, so if the sensor is already off when the step begins, it keeps waiting. And a restart of Home Assistant stops automations that are waiting, and they do not continue afterwards.
Further reading: Wait for a trigger, Home Assistant docs