Fix automation & script restart mode bug (#37909)

This commit is contained in:
Phil Bruckner 2020-07-16 14:03:43 -05:00 committed by GitHub
parent a224b944e9
commit 716cee6907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -760,14 +760,16 @@ class Script:
raise
async def _async_stop(self, update_state):
await asyncio.wait([run.async_stop() for run in self._runs])
aws = [run.async_stop() for run in self._runs]
if not aws:
return
await asyncio.wait(aws)
if update_state:
self._changed()
async def async_stop(self, update_state: bool = True) -> None:
"""Stop running script."""
if self.is_running:
await asyncio.shield(self._async_stop(update_state))
await asyncio.shield(self._async_stop(update_state))
async def _async_get_condition(self, config):
config_cache_key = frozenset((k, str(v)) for k, v in config.items())