Add recent context (#15989)

* Add recent context

* Add async_set_context to components not using new services
This commit is contained in:
Paulus Schoutsen 2018-08-20 17:39:53 +02:00 committed by GitHub
parent d1e1b9b38a
commit 1be61df9c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 211 additions and 11 deletions

View file

@ -218,13 +218,15 @@ async def _handle_service_platform_call(func, data, entities, context):
if not entity.available:
continue
entity.async_set_context(context)
if isinstance(func, str):
await getattr(entity, func)(**data)
else:
await func(entity, data)
if entity.should_poll:
tasks.append(entity.async_update_ha_state(True, context))
tasks.append(entity.async_update_ha_state(True))
if tasks:
await asyncio.wait(tasks)