core/homeassistant/components/config/group.py

28 lines
794 B
Python
Raw Normal View History

2017-02-21 05:53:55 +00:00
"""Provide configuration end points for Groups."""
from homeassistant.components.group import DOMAIN, GROUP_SCHEMA
from homeassistant.config import GROUP_CONFIG_PATH
from homeassistant.const import SERVICE_RELOAD
2017-02-21 05:53:55 +00:00
import homeassistant.helpers.config_validation as cv
from . import EditKeyBasedConfigView
2017-02-21 05:53:55 +00:00
async def async_setup(hass):
"""Set up the Group config API."""
2019-07-31 19:25:30 +00:00
async def hook(action, config_key):
"""post_write_hook for Config View that reloads groups."""
await hass.services.async_call(DOMAIN, SERVICE_RELOAD)
2019-07-31 19:25:30 +00:00
hass.http.register_view(
EditKeyBasedConfigView(
"group",
"config",
GROUP_CONFIG_PATH,
cv.slug,
GROUP_SCHEMA,
post_write_hook=hook,
2019-07-31 19:25:30 +00:00
)
)
2017-02-21 05:53:55 +00:00
return True