2017-02-12 19:31:46 +00:00
|
|
|
"""Component to interact with Hassbian tools."""
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
from homeassistant.components.http import HomeAssistantView
|
|
|
|
from homeassistant.config import async_check_ha_config_file
|
|
|
|
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def async_setup(hass):
|
2017-04-30 05:04:49 +00:00
|
|
|
"""Set up the Hassbian config."""
|
2017-02-12 19:31:46 +00:00
|
|
|
hass.http.register_view(CheckConfigView)
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
class CheckConfigView(HomeAssistantView):
|
|
|
|
"""Hassbian packages endpoint."""
|
|
|
|
|
|
|
|
url = '/api/config/core/check_config'
|
|
|
|
name = 'api:config:core:check_config'
|
|
|
|
|
|
|
|
@asyncio.coroutine
|
|
|
|
def post(self, request):
|
2017-04-30 05:04:49 +00:00
|
|
|
"""Validate configuration and return results."""
|
2017-02-12 19:31:46 +00:00
|
|
|
errors = yield from async_check_ha_config_file(request.app['hass'])
|
|
|
|
|
|
|
|
state = 'invalid' if errors else 'valid'
|
|
|
|
|
|
|
|
return self.json({
|
|
|
|
"result": state,
|
|
|
|
"errors": errors,
|
|
|
|
})
|