2017-02-21 05:53:55 +00:00
|
|
|
"""Provide configuration end points for Groups."""
|
|
|
|
import asyncio
|
2017-12-01 20:53:46 +00:00
|
|
|
from homeassistant.const import SERVICE_RELOAD
|
2017-02-21 05:53:55 +00:00
|
|
|
from homeassistant.components.config import EditKeyBasedConfigView
|
2017-12-01 20:53:46 +00:00
|
|
|
from homeassistant.components.group import DOMAIN, GROUP_SCHEMA
|
2017-02-21 05:53:55 +00:00
|
|
|
import homeassistant.helpers.config_validation as cv
|
|
|
|
|
|
|
|
|
|
|
|
CONFIG_PATH = 'groups.yaml'
|
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def async_setup(hass):
|
2017-04-30 05:04:49 +00:00
|
|
|
"""Set up the Group config API."""
|
2017-12-01 20:53:46 +00:00
|
|
|
@asyncio.coroutine
|
|
|
|
def hook(hass):
|
|
|
|
"""post_write_hook for Config View that reloads groups."""
|
|
|
|
yield from hass.services.async_call(DOMAIN, SERVICE_RELOAD)
|
|
|
|
|
2017-02-21 05:53:55 +00:00
|
|
|
hass.http.register_view(EditKeyBasedConfigView(
|
2017-12-01 20:53:46 +00:00
|
|
|
'group', 'config', CONFIG_PATH, cv.slug, GROUP_SCHEMA,
|
|
|
|
post_write_hook=hook
|
2017-02-21 05:53:55 +00:00
|
|
|
))
|
|
|
|
return True
|