New Events and Context Fixes (#18765)

* Add new events for automation trigger and script run, fix context for image processing, add tests to ensure same context

* remove custom logbook entry for automation and add new automation event to logbook

* code review updates
This commit is contained in:
Jason Hunter authored and Paulus Schoutsen committed 2018-12-04 09:45:17 +01:00
1 parent 8e9c73eb18
commit b900005d1e
8 files changed
+214 -19

No files matched your search

@@ -76,10 +76,14 @@ async def async_setup(hass, config):
"""Service handler for scan."""
image_entities = component.async_extract_from_service(service)
update_task = [entity.async_update_ha_state(True) for
entity in image_entities]
if update_task:
await asyncio.wait(update_task, loop=hass.loop)
update_tasks = []
for entity in image_entities:
entity.async_set_context(service.context)
update_tasks.append(
entity.async_update_ha_state(True))
if update_tasks:
await asyncio.wait(update_tasks, loop=hass.loop)
hass.services.async_register(
DOMAIN, SERVICE_SCAN, async_scan_service,