From b750319de43a4eb38c344de3e1aa529e4c9e4e5f Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 18 Dec 2016 21:57:31 +0100 Subject: [PATCH] Bugfix wait in automation (#4984) --- homeassistant/components/automation/__init__.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 9ff2fbd878a..341e6e90233 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -166,7 +166,9 @@ def async_setup(hass, config): for entity in component.async_extract_from_service(service_call): tasks.append(entity.async_trigger( service_call.data.get(ATTR_VARIABLES), True)) - yield from asyncio.wait(tasks, loop=hass.loop) + + if tasks: + yield from asyncio.wait(tasks, loop=hass.loop) @asyncio.coroutine def turn_onoff_service_handler(service_call): @@ -175,7 +177,9 @@ def async_setup(hass, config): method = 'async_{}'.format(service_call.service) for entity in component.async_extract_from_service(service_call): tasks.append(getattr(entity, method)()) - yield from asyncio.wait(tasks, loop=hass.loop) + + if tasks: + yield from asyncio.wait(tasks, loop=hass.loop) @asyncio.coroutine def toggle_service_handler(service_call): @@ -186,7 +190,9 @@ def async_setup(hass, config): tasks.append(entity.async_turn_off()) else: tasks.append(entity.async_turn_on()) - yield from asyncio.wait(tasks, loop=hass.loop) + + if tasks: + yield from asyncio.wait(tasks, loop=hass.loop) @asyncio.coroutine def reload_service_handler(service_call):