Files
home-assistant-core/homeassistant/components/config/script.py
T
cdce8p 70b901017f Remove service helper (5) (#16917)
* Update switch

* Update script

* Update light

* Fix tests

* Fix config/script hook

* Async_create_task

* Fix flux switch
2018-09-27 23:13:11 +02:00

25 lines
755 B
Python

"""Provide configuration end points for scripts."""
import asyncio
from homeassistant.components.config import EditKeyBasedConfigView
from homeassistant.components.script import DOMAIN, SCRIPT_ENTRY_SCHEMA
from homeassistant.const import SERVICE_RELOAD
import homeassistant.helpers.config_validation as cv
CONFIG_PATH = 'scripts.yaml'
@asyncio.coroutine
def async_setup(hass):
"""Set up the script config API."""
async def hook(hass):
"""post_write_hook for Config View that reloads scripts."""
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
hass.http.register_view(EditKeyBasedConfigView(
'script', 'config', CONFIG_PATH, cv.slug, SCRIPT_ENTRY_SCHEMA,
post_write_hook=hook
))
return True