Continue on Timeout - when does it continue?

I always thought that if I did something like this:

wait_for_trigger:
  - platform: state
    entity_id:
      - binary_sensor.tuya_mmwave_office_occupancy
    from: "on"
    for:
      hours: 0
      minutes: 2
      seconds: 0
continue_on_timeout: true
timeout:
  hours: 0
  minutes: 2
  seconds: 1
  milliseconds: 0

The automation would wait 2 minutes for the wait for trigger, then (in this case), timeout 1 second later.
However, looking in my logs, I think I’m reading that it takes a full 2 minutes and 1 second to timeout, even though its already waited a 2 minutes for the state to change.

Can someone confirm, correct me ?

What I believe yourwait_for_trigger will do is this:

It will wait for 2 minutes and 1 second for the trigger to occur. The trigger occurs when the state of the sensor is on for at least 2 minutes.

So the following could happen:

The sensor could have been on for 1 minute and 59 second when the wait begins. If the sensor remain on then the wait will only wait for 1 second.

The sensor state change to on 0.5 seconds after the wait begins and stays on for 2 minutes. The wait will end after 2 minutes and 0.5 seconds.

The sensor state changes to on 2 second after the wait begins. The sensor state can now never be on for 2 minutes before the wait ends. The wait ends after 2 minutes and 1 seconds.

And so on.

It’s often important to test how the wait ended in subsequent actions

@templeton_nash - Up until now, thats how I expected it to work, and re-checking my logs, looks like I just misread them. Thankyou for your confirmation.

1 Like