Skip to content

task.wait_until() appears to ignore the condition expression #839

@ryaowe

Description

@ryaowe

Bug description

task.wait_until() appears to ignore the condition expression.

  • Without a timeout, it returns immediately even though the condition is false.
  • With a timeout, it waits until the timeout expires even if the condition becomes true before then.

Environment

  • Pyscript version: 2.0.1 (also tried on 2.0.0) via HACS
  • Installation method: Home Assistant OS
  • Core: 2026.5.0
  • Supervisor: 2026.04.2
  • Operating System: 17.3
  • Frontend: 20260429.3

Reproduction

Create an input_boolean helper named input_boolean.test1.

Then use this pyscript:

@state_trigger("input_boolean.test1 == 'on'")
def test_wait_until():
    log.warning("input_boolean.test1 toggled on")

    result = task.wait_until("input_boolean.test1 == 'off'")

    log.warning(
        "test1 toggled off? %r %r",
        result,
        input_boolean.test1,
    )

Actual behavior

When input_boolean.test1 is turned on, the second log message appears immediately even though the condition is still false.

Log output:

2026-05-07 14:16:29.595 WARNING (MainThread) [custom_components.pyscript.file.waittest.test_wait_until] input_boolean.test1 toggled on
2026-05-07 14:16:29.595 WARNING (MainThread) [custom_components.pyscript.file.waittest.test_wait_until] test1 toggled off? {'trigger_type': 'none'} 'on'

Expected behavior

task.wait_until() should block until input_boolean.test1 == 'off'.


Timeout behavior

If I instead use:

@state_trigger("input_boolean.test1 == 'on'")
def test_wait_until():
    log.warning("input_boolean.test1 toggled on")

    result = task.wait_until(
        "input_boolean.test1 == 'off'",
        timeout=30,
    )

    log.warning(
        "test1 toggled off? %r %r",
        result,
        input_boolean.test1,
    )

and then:

  1. Turn input_boolean.test1 on
  2. Wait 10 seconds
  3. Turn it back off

the call still waits the full 30 seconds before returning.

Log output:

2026-05-07 14:19:35.877 WARNING (MainThread) [custom_components.pyscript.file.waittest.test_wait_until] input_boolean.test1 toggled on
2026-05-07 14:20:05.879 WARNING (MainThread) [custom_components.pyscript.file.waittest.test_wait_until] test1 toggled off? {'trigger_type': 'timeout'} 'off'

Expected behavior

The wait should end as soon as the condition becomes true, rather than waiting for the timeout to expire.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions