home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.67k stars 30.8k forks source link

Script, that turns on an already running script, hangs until that script finished #40237

Open OleksandrBerchenko opened 4 years ago

OleksandrBerchenko commented 4 years ago

The problem

Imagine the following scripts:

script_a:
  sequence:
  - delay:
      seconds: 0

script_b:
  sequence:
  - delay:
      seconds: 120

script_c:
  sequence:
  - delay:
      seconds: 0

script_d:
  sequence:
  - service: script.turn_on
    entity_id: script.script_a
  - service: script.turn_on
    entity_id: script.script_b
  - service: script.turn_on
    entity_id: script.script_c

If I just run script_d, then everything works as expected: all three "child" scripts are triggered and script_d finishes, script_a and script_c finish in a moment and script_b finishes in two minutes.

Now let's run script_b first, wait for a few seconds and then run script_d. As expected, when script_d triggers script_b, nothing happens. because the script is already running:

2020-09-18 10:30:18 WARNING (MainThread) [homeassistant.components.script.script_b] script_b: Already running

But instead of continuing to the next step, script_d hangs and starts to wait until the previous run of script_b finished! See the log below.

Environment

Problem-relevant configuration.yaml

n/a

Traceback/Error logs

2020-09-18 10:30:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=script.script_b>
2020-09-18 10:30:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=script_b, entity_id=script.script_b>
2020-09-18 10:30:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_b, old_state=<state script.script_b=off; last_triggered=None, mode=single, current=0, friendly_name=script_b @ 2020-09-18T10:24:56.064147+03:00>, new_state=<state script.script_b=on; last_triggered=2020-09-18T10:30:13.439877+03:00, mode=single, current=1, friendly_name=script_b @ 2020-09-18T10:30:13.440463+03:00>>
2020-09-18 10:30:13 INFO (MainThread) [homeassistant.components.script.script_b] script_b: Running script
2020-09-18 10:30:13 INFO (MainThread) [homeassistant.components.script.script_b] script_b: Executing step delay 0:02:00
2020-09-18 10:30:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_b, old_state=<state script.script_b=on; last_triggered=2020-09-18T10:30:13.439877+03:00, mode=single, current=1, friendly_name=script_b @ 2020-09-18T10:30:13.440463+03:00>, new_state=<state script.script_b=on; last_triggered=2020-09-18T10:30:13.439877+03:00, mode=single, current=1, last_action=delay 0:02:00, friendly_name=script_b @ 2020-09-18T10:30:13.440463+03:00>>

2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=script.script_d>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=script_d, entity_id=script.script_d>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_d, old_state=<state script.script_d=off; last_triggered=None, mode=single, current=0, friendly_name=script_d @ 2020-09-18T10:24:56.065323+03:00>, new_state=<state script.script_d=on; last_triggered=2020-09-18T10:30:18.817164+03:00, mode=single, current=1, friendly_name=script_d @ 2020-09-18T10:30:18.817927+03:00>>
2020-09-18 10:30:18 INFO (MainThread) [homeassistant.components.script.script_d] script_d: Running script
2020-09-18 10:30:18 INFO (MainThread) [homeassistant.components.script.script_d] script_d: Executing step call service
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=['script.script_a']>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=script_a, entity_id=script.script_a>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_a, old_state=<state script.script_a=off; last_triggered=None, mode=single, current=0, friendly_name=script_a @ 2020-09-18T10:24:56.063334+03:00>, new_state=<state script.script_a=on; last_triggered=2020-09-18T10:30:18.859116+03:00, mode=single, current=1, friendly_name=script_a @ 2020-09-18T10:30:18.859543+03:00>>
2020-09-18 10:30:18 INFO (MainThread) [homeassistant.components.script.script_a] script_a: Running script
2020-09-18 10:30:18 INFO (MainThread) [homeassistant.components.script.script_a] script_a: Executing step delay 0:00:00
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_a, old_state=<state script.script_a=on; last_triggered=2020-09-18T10:30:18.859116+03:00, mode=single, current=1, friendly_name=script_a @ 2020-09-18T10:30:18.859543+03:00>, new_state=<state script.script_a=on; last_triggered=2020-09-18T10:30:18.859116+03:00, mode=single, current=1, last_action=delay 0:00:00, friendly_name=script_a @ 2020-09-18T10:30:18.859543+03:00>>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_a, old_state=<state script.script_a=on; last_triggered=2020-09-18T10:30:18.859116+03:00, mode=single, current=1, last_action=delay 0:00:00, friendly_name=script_a @ 2020-09-18T10:30:18.859543+03:00>, new_state=<state script.script_a=off; last_triggered=2020-09-18T10:30:18.859116+03:00, mode=single, current=0, friendly_name=script_a @ 2020-09-18T10:30:18.879949+03:00>>
2020-09-18 10:30:18 INFO (MainThread) [homeassistant.components.script.script_d] script_d: Executing step call service
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=['script.script_b']>
2020-09-18 10:30:18 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=script_b, entity_id=script.script_b>
2020-09-18 10:30:18 WARNING (MainThread) [homeassistant.components.script.script_b] script_b: Already running

2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_b, old_state=<state script.script_b=on; last_triggered=2020-09-18T10:30:13.439877+03:00, mode=single, current=1, last_action=delay 0:02:00, friendly_name=script_b @ 2020-09-18T10:30:13.440463+03:00>, new_state=<state script.script_b=off; last_triggered=2020-09-18T10:30:13.439877+03:00, mode=single, current=0, friendly_name=script_b @ 2020-09-18T10:32:13.453092+03:00>>
2020-09-18 10:32:13 INFO (MainThread) [homeassistant.components.script.script_d] script_d: Executing step call service
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=script, service=turn_on, service_data=entity_id=['script.script_c']>
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event script_started[L]: name=script_c, entity_id=script.script_c>
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_c, old_state=<state script.script_c=off; last_triggered=None, mode=single, current=0, friendly_name=script_c @ 2020-09-18T10:24:56.064752+03:00>, new_state=<state script.script_c=on; last_triggered=2020-09-18T10:32:13.485586+03:00, mode=single, current=1, friendly_name=script_c @ 2020-09-18T10:32:13.486171+03:00>>
2020-09-18 10:32:13 INFO (MainThread) [homeassistant.components.script.script_c] script_c: Running script
2020-09-18 10:32:13 INFO (MainThread) [homeassistant.components.script.script_c] script_c: Executing step delay 0:00:00
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_c, old_state=<state script.script_c=on; last_triggered=2020-09-18T10:32:13.485586+03:00, mode=single, current=1, friendly_name=script_c @ 2020-09-18T10:32:13.486171+03:00>, new_state=<state script.script_c=on; last_triggered=2020-09-18T10:32:13.485586+03:00, mode=single, current=1, last_action=delay 0:00:00, friendly_name=script_c @ 2020-09-18T10:32:13.486171+03:00>>
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_c, old_state=<state script.script_c=on; last_triggered=2020-09-18T10:32:13.485586+03:00, mode=single, current=1, last_action=delay 0:00:00, friendly_name=script_c @ 2020-09-18T10:32:13.486171+03:00>, new_state=<state script.script_c=off; last_triggered=2020-09-18T10:32:13.485586+03:00, mode=single, current=0, friendly_name=script_c @ 2020-09-18T10:32:13.551107+03:00>>
2020-09-18 10:32:13 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=script.script_d, old_state=<state script.script_d=on; last_triggered=2020-09-18T10:30:18.817164+03:00, mode=single, current=1, friendly_name=script_d @ 2020-09-18T10:30:18.817927+03:00>, new_state=<state script.script_d=off; last_triggered=2020-09-18T10:30:18.817164+03:00, mode=single, current=0, friendly_name=script_d @ 2020-09-18T10:32:13.554062+03:00>>

Additional information

n/a

probot-home-assistant[bot] commented 4 years ago

Hey there @home-assistant/core, mind taking a look at this issue as its been labeled with an integration (script) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 3 years ago

Yes, it's still actual!

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 3 years ago

Yes, it's still actual!

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 3 years ago

Yes, it's still actual!

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 3 years ago

Yes, it's still actual!

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 2 years ago

Yes, it's still actual!

Blacksli commented 2 years ago

image image

image image

Problem exists

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 2 years ago

Yes, it's still actual!

chpego commented 2 years ago

The same here, i don't know why, delay doesn't work properly

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 1 year ago

Yes, it's still actual!

olyashok commented 1 year ago

I am running into this as well. @OleksandrBerchenko - did you find a workaround?

OleksandrBerchenko commented 1 year ago

Not really. Just tried to rewrite my scripts to avoid this situation.

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 1 year ago

Yes, it's still actual!

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 1 year ago

Yes, it's still actual!

issue-triage-workflows[bot] commented 10 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

olyashok commented 10 months ago

Still actgual

On Sat, Dec 30, 2023 at 6:05โ€ฏPM issue-triage-workflows[bot] < @.***> wrote:

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

โ€” Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/40237#issuecomment-1872622901, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBUT7VB6W44IUMEMJZ5U5TYMCM5NAVCNFSM4RR47JXKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBXGI3DEMRZGAYQ . You are receiving this because you commented.Message ID: @.***>

issue-triage-workflows[bot] commented 7 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 7 months ago

Yes, it's still actual!

issue-triage-workflows[bot] commented 4 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment ๐Ÿ‘ This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

OleksandrBerchenko commented 4 months ago

Yes, it's still actual!

jazzyisj commented 1 month ago

@OleksandrBerchenko

This seems like expected behavior to me.
Run the scripts in parallel mode.

https://www.home-assistant.io/integrations/script/#script-modes