From 23fb8c4cddeba13841504c84cace1ac0f4ad3b99 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 17 Nov 2016 21:50:01 -0800 Subject: [PATCH] Convert script component to async (#4427) --- homeassistant/components/script.py | 58 +++++++++++++++++++----------- tests/components/test_script.py | 5 +++ 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/script.py b/homeassistant/components/script.py index 8c521c33856..df46fb5a03d 100644 --- a/homeassistant/components/script.py +++ b/homeassistant/components/script.py @@ -7,6 +7,7 @@ by the user or automatically based upon automation events, etc. For more details about this component, please refer to the documentation at https://home-assistant.io/components/script/ """ +import asyncio import logging import voluptuous as vol @@ -72,11 +73,13 @@ def toggle(hass, entity_id): hass.services.call(DOMAIN, SERVICE_TOGGLE, {ATTR_ENTITY_ID: entity_id}) -def setup(hass, config): +@asyncio.coroutine +def async_setup(hass, config): """Load the scripts from the configuration.""" component = EntityComponent(_LOGGER, DOMAIN, hass, group_name=GROUP_NAME_ALL_SCRIPTS) + @asyncio.coroutine def service_handler(service): """Execute a service call to script.