Fix calling empty script turn off (#24827)
This commit is contained in:
parent
fafc68673a
commit
2886b217ab
2 changed files with 16 additions and 1 deletions
|
@ -79,9 +79,14 @@ async def async_setup(hass, config):
|
||||||
async def turn_off_service(service):
|
async def turn_off_service(service):
|
||||||
"""Cancel a script."""
|
"""Cancel a script."""
|
||||||
# Stopping a script is ok to be done in parallel
|
# Stopping a script is ok to be done in parallel
|
||||||
|
scripts = await component.async_extract_from_service(service)
|
||||||
|
|
||||||
|
if not scripts:
|
||||||
|
return
|
||||||
|
|
||||||
await asyncio.wait([
|
await asyncio.wait([
|
||||||
script.async_turn_off() for script
|
script.async_turn_off() for script
|
||||||
in await component.async_extract_from_service(service)
|
in scripts
|
||||||
])
|
])
|
||||||
|
|
||||||
async def toggle_service(service):
|
async def toggle_service(service):
|
||||||
|
|
|
@ -322,3 +322,13 @@ async def test_logging_script_error(hass, caplog):
|
||||||
assert err.value.domain == 'non'
|
assert err.value.domain == 'non'
|
||||||
assert err.value.service == 'existing'
|
assert err.value.service == 'existing'
|
||||||
assert 'Error executing script' in caplog.text
|
assert 'Error executing script' in caplog.text
|
||||||
|
|
||||||
|
|
||||||
|
async def test_turning_no_scripts_off(hass):
|
||||||
|
"""Test it is possible to turn two scripts off."""
|
||||||
|
assert await async_setup_component(hass, 'script', {})
|
||||||
|
|
||||||
|
# Testing it doesn't raise
|
||||||
|
await hass.services.async_call(
|
||||||
|
DOMAIN, SERVICE_TURN_OFF, {'entity_id': []}, blocking=True
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue