core icon indicating copy to clipboard operation
core copied to clipboard

"Wait for trigger" with defined but zero timeout timesout immediately

Open 20BBrown14 opened this issue 5 months ago • 6 comments

The problem

"Wait for trigger", wait_for_trigger actions with a defined but zero timeout fails to wait for one of the triggers and instead times out immediately.

timeout:
  hours: 0
  minutes: 0
  seconds: 0
  milliseconds: 0

What version of Home Assistant Core has the issue?

core-2024.1.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Automations

Link to integration documentation on our website

https://www.home-assistant.io/docs/automation/

Diagnostics information

No response

Example YAML snippet

wait_for_trigger:
  - platform: device
    type: turned_on
    device_id: <device_id>
    entity_id: <entity_id>
    domain: switch
timeout:
  hours: 0
  minutes: 0
  seconds: 0
  milliseconds: 0

Anything in the logs that might be useful for us?

No response

Additional information

No response

20BBrown14 avatar Feb 04 '24 04:02 20BBrown14

Hmm, what would you expect to happen in that case? Not time out at all?

TheJulianJES avatar Feb 06 '24 05:02 TheJulianJES

If the timeout is zero I would except it be treated as a null timeout. That makes sense to me at least.

On Mon, Feb 5, 2024, 11:22 PM TheJulianJES @.***> wrote:

Hmm, what would you expect to happen in that case? Not time out at all?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/109586#issuecomment-1928806372, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBJCWJIXTUP5QXBECCRMGDYSG4ZHAVCNFSM6AAAAABCYRYLGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYHAYDMMZXGI . You are receiving this because you authored the thread.Message ID: @.***>

20BBrown14 avatar Feb 06 '24 05:02 20BBrown14

You can just use continue_on_timeout: false in that case (instead of providing a timeout).

TheJulianJES avatar Feb 06 '24 05:02 TheJulianJES

Hm. Not sure how that solves the problem I think is present.

If I had provided a timeout previously and then switched it to a zero second timeout, I would like the automation to wait for the triggers indefinitely.

As is, if I set a timeout of zero and false for continue on timeout, the automation would immediately cancel not waiting for any of the triggers AND not continuing the script.

If the timeout is zero I would simply except it to be treated as null timeout and wait indefinitely. With a timeout of zero, the continue on timeout flag shouldn't change any behavior in my head.

On Mon, Feb 5, 2024, 11:57 PM TheJulianJES @.***> wrote:

You can just use continue_on_timeout: false in that case (instead of providing a timeout).

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/109586#issuecomment-1928836917, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBJCWI23KU2VMOGJOKBPGTYSHA4DAVCNFSM6AAAAABCYRYLGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRYHAZTMOJRG4 . You are receiving this because you authored the thread.Message ID: @.***>

20BBrown14 avatar Feb 06 '24 18:02 20BBrown14

But the behavior of waiting indefinitely for the triggers is the default one when you don't provide a timeout at all.

TheJulianJES avatar Feb 06 '24 19:02 TheJulianJES

Right. I guess this ends up being a question of whether a timeout of zero seconds is the same as no timeout. Which it seems you're saying it's not and that a timeout of zero seconds is exactly that. Just doesn't seem very intuitive.

Can we think of an actual use case where a timeout of zero seconds would be intended?

On Tue, Feb 6, 2024, 1:02 PM TheJulianJES @.***> wrote:

But the behavior of waiting indefinitely for the triggers is the default one when you don't provide a timeout at all.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/109586#issuecomment-1930575017, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBJCWMZOVKNIYO6A6WWEOTYSJ423AVCNFSM6AAAAABCYRYLGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZQGU3TKMBRG4 . You are receiving this because you authored the thread.Message ID: @.***>

20BBrown14 avatar Feb 06 '24 20:02 20BBrown14

I have also got probleme with this automation with the UI interface.

1 - when you create the automation without touching this timeout value, it's works fine. So zero ==> no time out.

2 - but il you put a value (ie : 1 min) and return at zéro, the automation works completely differently.

If buton continue_on_timeout = true
its continue imediatly. So zero ==> time out infinitely short at zero second. Same thing on the UI but different operation. it's very disturbing.

If buton continue_on_timeout: fals everything else is blocked. I don't understant

Nota : if I look at the Yaml, on the 1 (when i create) there is not time out defined. But on the 2 (when I write zero) the timeout is defined at zero.

Sorry for my english. I hope that is understandable.

vlacsap avatar Mar 06 '24 17:03 vlacsap

That's exactly the issue that happened to me that caused me to open this issue in the first place. If it's decided that the timeout should still operate as is, then the UI should be updated such that if you input 0 timeout it goes back to the default of no timeout

On Wed, Mar 6, 2024, 11:32 AM vlacsap @.***> wrote:

I have also got probleme with this automation with the UI interface.

1 - when you create the automation without touching this timeout value, it's works fine. So zero ==> no time out.

2 - but il you put a value (ie : 1 min) and return at zéro, the automation works completely differently.

If buton continue_on_timeout = true its continue imediatly. So zero ==> time out infinitely short at zero second. Same thing on the UI but different operation. it's very disturbing.

If buton continue_on_timeout: fals everything else is blocked. I don't understant

Nota : if I look at the Yaml, on the 1 (when i create) there is not time out defined. But on the 2 (when I write zero) the timeout is defined at zero.

Sorry for my english. I hope that is understandable.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/109586#issuecomment-1981421744, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHBJCWMC5VNLZ4AIDSGQPVLYW5HMBAVCNFSM6AAAAABCYRYLGKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBRGQZDCNZUGQ . You are receiving this because you authored the thread.Message ID: @.***>

20BBrown14 avatar Mar 06 '24 18:03 20BBrown14

But the behavior of waiting indefinitely for the triggers is the default one when you don't provide a timeout at all.

In the GUI "Wait for timeout" is described as optional, and by default the trigger does not timeout. As soon as you change the value, the section is added in the yaml code. If you change it back to zero, there is no way to see that you have added the zero timeout if you only look in the GUI.

The GUI makes no difference between a timeout of 0 s and no timeout at all. So it looks the same but behaves radically different.

GUI-wise this would need some kind of checkbox.

danka621 avatar Mar 28 '24 01:03 danka621

Are there any changes in behavior regarding this with Home Assistant Core 2024.4.x?

TheJulianJES avatar Apr 19 '24 00:04 TheJulianJES

@bdraco I cannot comment on https://github.com/home-assistant/core/pull/115830. To me, having a 0 timeout makes absolutely no sense. A 0 timeout should be treated as 'no timeout' not '0s timeout'. If a user wants a '0s timeout', they have the option of a '1ms timeout'. Currently you MUST have a timeout, unless you re-create the 'wait for trigger' and then never touch the timeout. Now I must go through and re-do a bunch of 'wait for trigger' automations, because I tried a timeout, didn't like it, and now my automatons are broken because the timeout thinks it is 0 seconds instead of 'no timeout'.

Surgikill avatar Apr 26 '24 03:04 Surgikill

Related to https://github.com/home-assistant/frontend/issues/19360#issuecomment-2078744325

srescio avatar Apr 26 '24 08:04 srescio