Bugfix wait in automation (#4984)

This commit is contained in:
Pascal Vizeli 2016-12-18 21:57:31 +01:00 committed by Paulus Schoutsen
parent f8af6e7863
commit a6d995e394

View File

@ -166,6 +166,8 @@ def async_setup(hass, config):
for entity in component.async_extract_from_service(service_call): for entity in component.async_extract_from_service(service_call):
tasks.append(entity.async_trigger( tasks.append(entity.async_trigger(
service_call.data.get(ATTR_VARIABLES), True)) service_call.data.get(ATTR_VARIABLES), True))
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop) yield from asyncio.wait(tasks, loop=hass.loop)
@asyncio.coroutine @asyncio.coroutine
@ -175,6 +177,8 @@ def async_setup(hass, config):
method = 'async_{}'.format(service_call.service) method = 'async_{}'.format(service_call.service)
for entity in component.async_extract_from_service(service_call): for entity in component.async_extract_from_service(service_call):
tasks.append(getattr(entity, method)()) tasks.append(getattr(entity, method)())
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop) yield from asyncio.wait(tasks, loop=hass.loop)
@asyncio.coroutine @asyncio.coroutine
@ -186,6 +190,8 @@ def async_setup(hass, config):
tasks.append(entity.async_turn_off()) tasks.append(entity.async_turn_off())
else: else:
tasks.append(entity.async_turn_on()) tasks.append(entity.async_turn_on())
if tasks:
yield from asyncio.wait(tasks, loop=hass.loop) yield from asyncio.wait(tasks, loop=hass.loop)
@asyncio.coroutine @asyncio.coroutine