Synchronous Scripts Support

Has anybody figured out how the new synchronous script support described here is supposed to work?

I haven’t been able to find anything in the docs yet.

because nothing will change on the surface. All changes are under the hood. This will just ‘work’.

quote

This PR is the first step towards resolving those issues. It improves the Script helper to properly support multiple, simultaneous runs, with options to provide usage flexibility. However, by default, it implements the current behavior to avoid breakage.

that’s probably why

I’m not sure that will be the case. I think the idea is that eventually if the script is already running you’re supposed to be able to specify whether to raise an error, restart the script, run parallel etc.

I have scripts that if called again I want the second call to just be ignored. I have other scripts that if they are called again I want them to wait and run when the first instance has finished. I’m pretty sure I even have a couple scripts that could just run simultaneously if called twice.

Home Assistant decide which mode to run if one cannot specify?

But the PR you linked has none of the changes regarding configuration. All the changes are in the hass api.

I understand it won’t all be implemented at once. However it does indicate.

This is an attempt to implement the new restart behavior described below

I haven’t noticed any change in behavior, so I was just wondering if something needed to be enabled.

have you read the last sentence of the quote? 8[ ]

I don’t think he has… He’s thinking that

  • error Raise an exception
  • ignore Return without doing anything (previous run continues as-is)
  • parallel Start run in new task
  • restart Stop previous run before starting new run

are exposed to scripts currently.

They are not. There’s a good chance that they won’t either. There will most likely be new services related to this.

1 Like

As soon as it’s still “under the hood” I just don’t want to take out my crystal ball :wink:

If you are referring to this.then yes. And that is what I have observed. I’m not confused about that part. I was just asking how it works. If it’s not a user specified parameter then how will Home Assistant decide what to do?

I didn’t think it was an absurd question and I did make an effort to try and figure it out myself. There is obviously something I’m not grasping.

My apologies for bothering you gents on this fine day.

The next phrase reads

The intention is to ultimately remove the so-called “legacy” behaviour.

so as far as I understand ultimately nothing like

relax, it’s not ready yet :wink:

This is all that needed to be said. I am still curious how HA will decided to run parallel or blocking mode but I guess it’s wait and see. I will admit I am quite anxious for this feature to appear. It will definitely simplify some things for me.

Thank you.

You’re just early.

It’s going to follow the Home assistant paradigm.

It will most likely be one of the following

  • new service
  • new data attribute for scripts.turn_on service (which may also be applied to the script.xxx services)

I understand this now. I was mistakenly under the impression from the text in the PR that the “restart” functionality is what was actually implemented in this release. Apparently this is not the case.

I was assuming it might be something like the following, but at this point you’re saying we just don’t know yet and I can live with that. Thank you.

service: script.somescript
data:
  runmode: parallel

the pr system isn’t very clear with that, but typically you’d see configuration changes and documentation changes for a pr that affects the user. Whenever you see them mention async_ blah blah blah method, they are talking about stuff that users won’t touch (unless you develop).