New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate optional script context #39034
Conversation
Hey there @PhracturedBlue, @tetienne, mind taking a look at this pull request as its been labeled with an integration ( |
I was getting this test failure locally too but I don't really understand why. @pnbruckner do you maybe have a hint? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor feedback.
Also, regarding the test that is failing (test_repeat_conditional
in tests/helpers/test_script.py
), although it hadn't failed for me, it does look like I left out one call to wait_started.clear()
, specifically after line 922:
for index in range(2, count + 1):
await asyncio.wait_for(wait_started.wait(), 1)
wait_started.clear()
hass.states.async_set("sensor.test", "next")
await asyncio.wait_for(wait_started.wait(), 1)
wait_started.clear()
hass.states.async_set("sensor.test", index)
await asyncio.wait_for(wait_started.wait(), 1)
wait_started.clear() # <==== add this line
hass.states.async_set("sensor.test", "next")
await asyncio.wait_for(wait_started.wait(), 1)
wait_started.clear()
hass.states.async_set("sensor.test", "done")
await asyncio.wait_for(hass.async_block_till_done(), 1)
Co-authored-by: Phil Bruckner <pnbruckner@gmail.com>
e497e03
to
0417a3a
Compare
Breaking change
Custom components: It is deprecated to not pass a context to
script.async_run()
. This will now print a warning. If you're inside an entity, useself._context
.Proposed change
This makes it mandatory to pass a context to
script.async_run
. If not passed in, it will print a warning so custom integrations get time to adapt.Context will now also be available as one of the variables inside a script. This will make it easy to see if a state has been last changed by the script itself.
Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: