hass-core/homeassistant/components/config/script.py
Paulus Schoutsen 93f9afcd21
Fix config imports (#27669)
* Fix config imports

* Remove old migration

* Remove migrate tests
2019-10-15 16:15:26 -07:00

27 lines
801 B
Python

"""Provide configuration end points for scripts."""
from homeassistant.components.script import DOMAIN, SCRIPT_ENTRY_SCHEMA
from homeassistant.const import SERVICE_RELOAD
from homeassistant.config import SCRIPT_CONFIG_PATH
import homeassistant.helpers.config_validation as cv
from . import EditKeyBasedConfigView
async 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",
SCRIPT_CONFIG_PATH,
cv.slug,
SCRIPT_ENTRY_SCHEMA,
post_write_hook=hook,
)
)
return True