#wait_for_trigger with 'for' condition gets stuck when condition is already true

1 messages · Page 1 of 1 (latest)

ashen wadi
#

Home Assistant Version: 2025.8.3
Installation Type: OS

Description

I'm experiencing an issue with wait_for_trigger when using the for parameter. The automation gets stuck indefinitely when the trigger condition is already true at the time the wait_for_trigger is executed.

Expected Behavior

When wait_for_trigger is executed and the condition is already true, it should:

  1. Recognize the condition is met
  2. Start the timer (10 minutes in my case)
  3. Continue execution after the timer expires if condition remains true

Actual Behavior

When the automation reaches wait_for_trigger and the sensor value is already above the threshold (≥160W), the automation gets stuck in an infinite wait state and never proceeds, even though the condition remains true continuously.

Configuration

- wait_for_trigger:
    - value_template: "{{ states('sensor.2_shem_channel_1_power') | float(0) >= 160 }}"
      for:
        minutes: 10
      trigger: template
      alias: "Wait until power sensor stays >= 160 for 10 continuous minutes"

Steps to Reproduce

  1. Set up automation with wait_for_trigger using for condition
  2. Ensure the sensor value is already above threshold before automation reaches this step
  3. Observe that automation never proceeds beyond wait_for_trigger

Workaround Found

The issue only occurs when condition is already true. If the sensor value drops below threshold and then rises above it again, the wait_for_trigger works correctly.

Questions

  1. Has anyone else experienced this behavior?
  2. Is this a known bug or expected behavior?
  3. Are there recommended patterns for handling this scenario?

Environment Details

  • Sensor: Power monitoring sensor (numeric values)
  • Values are stable (no rapid fluctuations)
  • No unavailable/unknown states during testing

Any insights or similar experiences would be greatly appreciated!

Mauro

merry raptor
#

This is expected behavior for any trigger

stable knoll
#

A trigger must be triggered (sounds a bit silly, I know).
For it to be triggered, it has to change its state from false to true. It is waiting to BECOME true. I'd say, it is expected behavior.
I think, a wait for template can do that.

ashen wadi
#

Hoo, How do you recommend I solve this?

stable knoll
#

A wait for template action if you don't care about the for 10 minutes part.

  - wait_template: "{{ states('sensor.2_shem_channel_1_power') | float(0) >= 160 }}"
    continue_on_timeout: false

Or a template binary sensor. That supports delays. And use that binary sensor as trigger or wait for template.

winged ledge
#

Or you just add an if statement before and check:
if not true, wait for trigger

merry raptor
#

Could have a race condition

ashen wadi
#

@merry raptor I don't understand the race condition.
@winged ledge I'll use a binary sensor. I was hoping for a solution without any external work on the automation.