Move GoogleConfig initialization into setup of component (#29170)
parent
3ecf5596ff
commit
69991bf3a2
|
@ -32,7 +32,7 @@ from .const import (
|
|||
)
|
||||
from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401
|
||||
from .const import EVENT_QUERY_RECEIVED # noqa: F401
|
||||
from .http import async_register_http
|
||||
from .http import GoogleAssistantView, GoogleConfig
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -93,7 +93,12 @@ CONFIG_SCHEMA = vol.Schema({DOMAIN: GOOGLE_ASSISTANT_SCHEMA}, extra=vol.ALLOW_EX
|
|||
async def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
|
||||
"""Activate Google Actions component."""
|
||||
config = yaml_config.get(DOMAIN, {})
|
||||
google_config = async_register_http(hass, config)
|
||||
google_config = GoogleConfig(hass, config)
|
||||
|
||||
hass.http.register_view(GoogleAssistantView(google_config))
|
||||
|
||||
if google_config.should_report_state:
|
||||
google_config.async_enable_report_state()
|
||||
|
||||
async def request_sync_service_handler(call: ServiceCall):
|
||||
"""Handle request sync service calls."""
|
||||
|
|
|
@ -10,7 +10,6 @@ from aiohttp.web import Request, Response
|
|||
|
||||
# Typing imports
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
@ -225,16 +224,6 @@ class GoogleConfig(AbstractConfig):
|
|||
await self.async_call_homegraph_api(REPORT_STATE_BASE_URL, data)
|
||||
|
||||
|
||||
@callback
|
||||
def async_register_http(hass, cfg):
|
||||
"""Register HTTP views for Google Assistant."""
|
||||
config = GoogleConfig(hass, cfg)
|
||||
hass.http.register_view(GoogleAssistantView(config))
|
||||
if config.should_report_state:
|
||||
config.async_enable_report_state()
|
||||
return config
|
||||
|
||||
|
||||
class GoogleAssistantView(HomeAssistantView):
|
||||
"""Handle Google Assistant requests."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue