Allow wait template to run the remainder of the script#15836
Allow wait template to run the remainder of the script#15836balloob merged 5 commits intohome-assistant:devfrom
Conversation
…e script on timeout
homeassistant/helpers/script.py
Outdated
|
|
||
| @callback | ||
| def async_script_wait(entity_id, from_s, to_s): | ||
| def async_script_wait(entity_id, from_s = None, to_s = None): |
There was a problem hiding this comment.
unexpected spaces around keyword / parameter equals
|
|
||
| from homeassistant.const import ( | ||
| CONF_PLATFORM, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT, | ||
| CONF_PLATFORM, CONF_PROCEED, CONF_SCAN_INTERVAL, TEMP_CELSIUS, TEMP_FAHRENHEIT, |
|
Thanks for your contribution. There are several outstanding issues in your pull request you have to resolve before review.
|
Thanks for your patience walking me through my first home-assistant PR |
|
Regarding Example entry for configuration.yaml
I want to see the "example config" to demo how to set
I want to see a example to demo "Wait Template script to use a timer" It should be something similar with your unit test case, but write it in yaml format. |
homeassistant/const.py
Outdated
| CONF_PENDING_TIME = 'pending_time' | ||
| CONF_PIN = 'pin' | ||
| CONF_PLATFORM = 'platform' | ||
| CONF_PROCEED = 'proceed' |
There was a problem hiding this comment.
proceed is not self-explain to me. How about continue_on_timeout
And it should resident in helpers/script.py together with CONF_WAIT_TEMPLATE.
homeassistant/helpers/script.py
Outdated
| self.hass.async_add_job(self._change_listener) | ||
|
|
||
| # Allow proceed to be false by default | ||
| proceed = False |
There was a problem hiding this comment.
No need declare here, should put it inside if CONF_TIMEOUT
homeassistant/helpers/script.py
Outdated
| # Check if we want to proceed to execute | ||
| # the script after the timeout | ||
| # or exit as the default behaviour | ||
| if proceed: |
There was a problem hiding this comment.
if action.get(CONF_PROCEED, False):
homeassistant/helpers/script.py
Outdated
| # Check if we want to proceed to execute | ||
| # the script after the timeout | ||
| # or exit as the default behaviour | ||
| if proceed: |
There was a problem hiding this comment.
Actually, if I were you, I will extend self._async_set_timeout method to accept the 3rd parameter as the callback method when timeout occurred. If the 3rd parameter is None, then keep current logic. If we want to continue run after timeout, we can simply pass in async_script_wait.
|
Thanks, I was battling with the correct word to use. I have moved the "if CONF_CONTINUE" inside the _async_set_timeout. If your happy with the change I will update the supporting docs with the new variable name I will endeavour to do this tomorrow |
awarecan
left a comment
There was a problem hiding this comment.
LGTM, doc need to change reflect latest change
|
Not convinced the code is working as expected, when running on my home system. |
|
I think we should consider for this to be the default. |
|
I would love for this to be the default, though that would make it a breaking change. |
|
I agree with @amelchio that this should be the default behavior. |
|
I have spent the last week testing the present code and it is working as expected on my system |
|
As I have only just started to use Home Assistant and contribute back, I can change the code and update the docs, is there anything else that needs to be done? |
|
Having @balloob on board is enough :) You tag the PR with "breaking change" and add a small note at the top describing the incompatibility. This note is copied to the release note and that's that. |
|
Either I am missing how to add a label, or I don't have permission. Thanks |
|
🎉 thanks for the great contribution! |
|
Thanks for being so inviting to your project! |
…t#15836) * Adding new feature to allow a wait template to run the remainer of the script on timeout * Styling changes * Fixing file permissions, adding test for new code * changed variable name, refactored script to pass information into async_set_timeout * Changing the default behaviour to continue to run the script after timeout
…t#15836) * Adding new feature to allow a wait template to run the remainer of the script on timeout * Styling changes * Fixing file permissions, adding test for new code * changed variable name, refactored script to pass information into async_set_timeout * Changing the default behaviour to continue to run the script after timeout
New feature: allow wait template to run the remainder of the script
Breaking changes
The wait template will now continue to run the remainder of the script on timeout, the original functionality can be gained by setting
continue_on_timeout: false.Description:
This allows the Wait Template script to use a timer to continue running the script if timeout is reached vs the current behaviour of exiting.
This is achieved by setting a new flag 'proceed' to 'true' in the config.
By default this flag is set to 'false' and is optional to ensure this is not a breaking change.
For this flag to work the optional 'timeout' is required to be set also.
Pull request in home-assistant.github.io with documentation (if applicable):
home-assistant/home-assistant.io#5954
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed: