diff --git a/homeassistant/components/cloud/__init__.py b/homeassistant/components/cloud/__init__.py index 71550fc37b1..a2c79fdc0a7 100644 --- a/homeassistant/components/cloud/__init__.py +++ b/homeassistant/components/cloud/__init__.py @@ -1,6 +1,7 @@ """Component to integrate the Home Assistant cloud.""" import logging +from hass_nabucasa import Cloud import voluptuous as vol from homeassistant.auth.const import GROUP_ID_ADMIN @@ -20,25 +21,26 @@ from homeassistant.loader import bind_hass from homeassistant.util.aiohttp import MockRequest from . import http_api +from .client import CloudClient from .const import ( CONF_ACME_DIRECTORY_SERVER, CONF_ALEXA, + CONF_ALEXA_ACCESS_TOKEN_URL, CONF_ALIASES, CONF_CLOUDHOOK_CREATE_URL, CONF_COGNITO_CLIENT_ID, CONF_ENTITY_CONFIG, CONF_FILTER, CONF_GOOGLE_ACTIONS, + CONF_GOOGLE_ACTIONS_REPORT_STATE_URL, CONF_GOOGLE_ACTIONS_SYNC_URL, CONF_RELAYER, CONF_REMOTE_API_URL, CONF_SUBSCRIPTION_INFO_URL, CONF_USER_POOL_ID, - CONF_GOOGLE_ACTIONS_REPORT_STATE_URL, DOMAIN, MODE_DEV, MODE_PROD, - CONF_ALEXA_ACCESS_TOKEN_URL, ) from .prefs import CloudPreferences @@ -166,8 +168,6 @@ def is_cloudhook_request(request): async def async_setup(hass, config): """Initialize the Home Assistant cloud.""" - from hass_nabucasa import Cloud - from .client import CloudClient # Process configs if DOMAIN in config: diff --git a/homeassistant/components/cloud/http_api.py b/homeassistant/components/cloud/http_api.py index f243eab8fd0..97c96b0a3e8 100644 --- a/homeassistant/components/cloud/http_api.py +++ b/homeassistant/components/cloud/http_api.py @@ -3,33 +3,34 @@ import asyncio from functools import wraps import logging -import attr import aiohttp import async_timeout +import attr +from hass_nabucasa import Cloud, auth +from hass_nabucasa.const import STATE_DISCONNECTED import voluptuous as vol -from hass_nabucasa import Cloud -from homeassistant.core import callback -from homeassistant.components.http import HomeAssistantView -from homeassistant.components.http.data_validator import RequestDataValidator from homeassistant.components import websocket_api -from homeassistant.components.websocket_api import const as ws_const from homeassistant.components.alexa import ( entities as alexa_entities, errors as alexa_errors, ) from homeassistant.components.google_assistant import helpers as google_helpers +from homeassistant.components.http import HomeAssistantView +from homeassistant.components.http.data_validator import RequestDataValidator +from homeassistant.components.websocket_api import const as ws_const +from homeassistant.core import callback from .const import ( DOMAIN, - REQUEST_TIMEOUT, + PREF_ALEXA_REPORT_STATE, PREF_ENABLE_ALEXA, PREF_ENABLE_GOOGLE, + PREF_GOOGLE_REPORT_STATE, PREF_GOOGLE_SECURE_DEVICES_PIN, + REQUEST_TIMEOUT, InvalidTrustedNetworks, InvalidTrustedProxies, - PREF_ALEXA_REPORT_STATE, - PREF_GOOGLE_REPORT_STATE, RequireRelink, ) @@ -104,8 +105,6 @@ async def async_setup(hass): hass.http.register_view(CloudResendConfirmView) hass.http.register_view(CloudForgotPasswordView) - from hass_nabucasa import auth - _CLOUD_ERRORS.update( { auth.UserNotFound: (400, "User does not exist."), @@ -320,7 +319,6 @@ def _require_cloud_login(handler): @websocket_api.async_response async def websocket_subscription(hass, connection, msg): """Handle request for account info.""" - from hass_nabucasa.const import STATE_DISCONNECTED cloud = hass.data[DOMAIN] @@ -417,7 +415,6 @@ async def websocket_hook_delete(hass, connection, msg): def _account_data(cloud): """Generate the auth data JSON response.""" - from hass_nabucasa.const import STATE_DISCONNECTED if not cloud.is_logged_in: return {"logged_in": False, "cloud": STATE_DISCONNECTED}