diff --git a/homeassistant/components/google_assistant/__init__.py b/homeassistant/components/google_assistant/__init__.py index ecb6d767817..f34a8e342c4 100644 --- a/homeassistant/components/google_assistant/__init__.py +++ b/homeassistant/components/google_assistant/__init__.py @@ -1,34 +1,33 @@ """Support for Actions on Google Assistant Smart Home Control.""" import logging -from typing import Dict, Any +from typing import Any, Dict import voluptuous as vol # Typing imports -from homeassistant.core import HomeAssistant, ServiceCall - from homeassistant.const import CONF_NAME +from homeassistant.core import HomeAssistant, ServiceCall from homeassistant.helpers import config_validation as cv from .const import ( - DOMAIN, - CONF_PROJECT_ID, - CONF_EXPOSE_BY_DEFAULT, - DEFAULT_EXPOSE_BY_DEFAULT, - CONF_EXPOSED_DOMAINS, - DEFAULT_EXPOSED_DOMAINS, + CONF_ALIASES, + CONF_ALLOW_UNLOCK, CONF_API_KEY, - SERVICE_REQUEST_SYNC, + CONF_CLIENT_EMAIL, CONF_ENTITY_CONFIG, CONF_EXPOSE, - CONF_ALIASES, + CONF_EXPOSE_BY_DEFAULT, + CONF_EXPOSED_DOMAINS, + CONF_PRIVATE_KEY, + CONF_PROJECT_ID, CONF_REPORT_STATE, CONF_ROOM_HINT, - CONF_ALLOW_UNLOCK, CONF_SECURE_DEVICES_PIN, CONF_SERVICE_ACCOUNT, - CONF_CLIENT_EMAIL, - CONF_PRIVATE_KEY, + DEFAULT_EXPOSE_BY_DEFAULT, + DEFAULT_EXPOSED_DOMAINS, + DOMAIN, + SERVICE_REQUEST_SYNC, ) from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401 from .const import EVENT_QUERY_RECEIVED # noqa: F401 diff --git a/homeassistant/components/google_assistant/const.py b/homeassistant/components/google_assistant/const.py index 35a04e0e08e..dcb87d1d93d 100644 --- a/homeassistant/components/google_assistant/const.py +++ b/homeassistant/components/google_assistant/const.py @@ -1,5 +1,6 @@ """Constants for Google Assistant.""" from homeassistant.components import ( + alarm_control_panel, binary_sensor, camera, climate, @@ -15,7 +16,6 @@ from homeassistant.components import ( sensor, switch, vacuum, - alarm_control_panel, ) DOMAIN = "google_assistant" diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 09859c5d3d0..8a847eca705 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -7,26 +7,26 @@ from typing import List, Optional from aiohttp.web import json_response -from homeassistant.core import Context, callback, HomeAssistant, State -from homeassistant.helpers.event import async_call_later from homeassistant.components import webhook -from homeassistant.helpers.storage import Store from homeassistant.const import ( + ATTR_DEVICE_CLASS, + ATTR_SUPPORTED_FEATURES, + CLOUD_NEVER_EXPOSED_ENTITIES, CONF_NAME, STATE_UNAVAILABLE, - ATTR_SUPPORTED_FEATURES, - ATTR_DEVICE_CLASS, - CLOUD_NEVER_EXPOSED_ENTITIES, ) +from homeassistant.core import Context, HomeAssistant, State, callback +from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.storage import Store from . import trait from .const import ( + CONF_ALIASES, + CONF_ROOM_HINT, + DEVICE_CLASS_TO_GOOGLE_TYPES, DOMAIN, DOMAIN_TO_GOOGLE_TYPES, - CONF_ALIASES, ERR_FUNCTION_NOT_SUPPORTED, - DEVICE_CLASS_TO_GOOGLE_TYPES, - CONF_ROOM_HINT, STORE_AGENT_USER_IDS, ) from .error import SmartHomeError @@ -119,6 +119,7 @@ class AbstractConfig: def async_enable_report_state(self): """Enable proactive mode.""" # Circular dep + # pylint: disable=import-outside-toplevel from .report_state import async_enable_report_state if self._unsub_report_state is None: @@ -213,6 +214,8 @@ class AbstractConfig: async def _handle_local_webhook(self, hass, webhook_id, request): """Handle an incoming local SDK message.""" + # Circular dep + # pylint: disable=import-outside-toplevel from . import smart_home payload = await request.json() diff --git a/homeassistant/components/google_assistant/http.py b/homeassistant/components/google_assistant/http.py index c3d0dd493a8..233923e97a9 100644 --- a/homeassistant/components/google_assistant/http.py +++ b/homeassistant/components/google_assistant/http.py @@ -3,10 +3,10 @@ import asyncio from datetime import timedelta import logging from uuid import uuid4 -import jwt -from aiohttp import ClientResponseError, ClientError +from aiohttp import ClientError, ClientResponseError from aiohttp.web import Request, Response +import jwt # Typing imports from homeassistant.components.http import HomeAssistantView @@ -15,24 +15,24 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.util import dt as dt_util from .const import ( - GOOGLE_ASSISTANT_API_ENDPOINT, CONF_API_KEY, - CONF_EXPOSE_BY_DEFAULT, - CONF_EXPOSED_DOMAINS, + CONF_CLIENT_EMAIL, CONF_ENTITY_CONFIG, CONF_EXPOSE, + CONF_EXPOSE_BY_DEFAULT, + CONF_EXPOSED_DOMAINS, + CONF_PRIVATE_KEY, CONF_REPORT_STATE, CONF_SECURE_DEVICES_PIN, CONF_SERVICE_ACCOUNT, - CONF_CLIENT_EMAIL, - CONF_PRIVATE_KEY, - HOMEGRAPH_TOKEN_URL, + GOOGLE_ASSISTANT_API_ENDPOINT, HOMEGRAPH_SCOPE, + HOMEGRAPH_TOKEN_URL, REPORT_STATE_BASE_URL, REQUEST_SYNC_BASE_URL, ) -from .smart_home import async_handle_message from .helpers import AbstractConfig +from .smart_home import async_handle_message _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/google_assistant/report_state.py b/homeassistant/components/google_assistant/report_state.py index 78a0f50e277..1e8b6c020de 100644 --- a/homeassistant/components/google_assistant/report_state.py +++ b/homeassistant/components/google_assistant/report_state.py @@ -1,12 +1,12 @@ """Google Report State implementation.""" import logging -from homeassistant.core import HomeAssistant, callback from homeassistant.const import MATCH_ALL +from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.event import async_call_later -from .helpers import AbstractConfig, GoogleEntity, async_get_entities from .error import SmartHomeError +from .helpers import AbstractConfig, GoogleEntity, async_get_entities # Time to wait until the homegraph updates # https://github.com/actions-on-google/smart-home-nodejs/issues/196#issuecomment-439156639 diff --git a/homeassistant/components/google_assistant/smart_home.py b/homeassistant/components/google_assistant/smart_home.py index 0e5037ce13a..b111e6dc942 100644 --- a/homeassistant/components/google_assistant/smart_home.py +++ b/homeassistant/components/google_assistant/smart_home.py @@ -3,20 +3,19 @@ import asyncio from itertools import product import logging +from homeassistant.const import ATTR_ENTITY_ID, __version__ from homeassistant.util.decorator import Registry -from homeassistant.const import ATTR_ENTITY_ID, __version__ - from .const import ( - ERR_PROTOCOL_ERROR, ERR_DEVICE_OFFLINE, + ERR_PROTOCOL_ERROR, ERR_UNKNOWN_ERROR, EVENT_COMMAND_RECEIVED, - EVENT_SYNC_RECEIVED, EVENT_QUERY_RECEIVED, + EVENT_SYNC_RECEIVED, ) -from .helpers import RequestData, GoogleEntity, async_get_entities from .error import SmartHomeError +from .helpers import GoogleEntity, RequestData, async_get_entities HANDLERS = Registry() _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 5b089459d83..40def0cb464 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -2,66 +2,67 @@ import logging from homeassistant.components import ( + alarm_control_panel, binary_sensor, camera, cover, - group, fan, + group, input_boolean, - media_player, light, lock, + media_player, scene, script, sensor, switch, vacuum, - alarm_control_panel, ) from homeassistant.components.climate import const as climate from homeassistant.const import ( - ATTR_ENTITY_ID, + ATTR_ASSUMED_STATE, + ATTR_CODE, ATTR_DEVICE_CLASS, + ATTR_ENTITY_ID, + ATTR_SUPPORTED_FEATURES, + ATTR_TEMPERATURE, + SERVICE_ALARM_ARM_AWAY, + SERVICE_ALARM_ARM_CUSTOM_BYPASS, + SERVICE_ALARM_ARM_HOME, + SERVICE_ALARM_ARM_NIGHT, + SERVICE_ALARM_DISARM, + SERVICE_ALARM_TRIGGER, SERVICE_TURN_OFF, SERVICE_TURN_ON, + STATE_ALARM_ARMED_AWAY, + STATE_ALARM_ARMED_CUSTOM_BYPASS, + STATE_ALARM_ARMED_HOME, + STATE_ALARM_ARMED_NIGHT, + STATE_ALARM_DISARMED, + STATE_ALARM_PENDING, + STATE_ALARM_TRIGGERED, STATE_LOCKED, STATE_OFF, STATE_ON, + STATE_UNKNOWN, TEMP_CELSIUS, TEMP_FAHRENHEIT, - ATTR_SUPPORTED_FEATURES, - ATTR_TEMPERATURE, - ATTR_ASSUMED_STATE, - SERVICE_ALARM_DISARM, - SERVICE_ALARM_ARM_HOME, - SERVICE_ALARM_ARM_AWAY, - SERVICE_ALARM_ARM_NIGHT, - SERVICE_ALARM_ARM_CUSTOM_BYPASS, - SERVICE_ALARM_TRIGGER, - STATE_ALARM_ARMED_HOME, - STATE_ALARM_ARMED_AWAY, - STATE_ALARM_ARMED_NIGHT, - STATE_ALARM_ARMED_CUSTOM_BYPASS, - STATE_ALARM_DISARMED, - STATE_ALARM_TRIGGERED, - STATE_ALARM_PENDING, - ATTR_CODE, - STATE_UNKNOWN, ) from homeassistant.core import DOMAIN as HA_DOMAIN from homeassistant.util import color as color_util, temperature as temp_util + from .const import ( - ERR_VALUE_OUT_OF_RANGE, - ERR_NOT_SUPPORTED, - ERR_FUNCTION_NOT_SUPPORTED, - ERR_CHALLENGE_NOT_SETUP, CHALLENGE_ACK_NEEDED, - CHALLENGE_PIN_NEEDED, CHALLENGE_FAILED_PIN_NEEDED, - ERR_ALREADY_DISARMED, + CHALLENGE_PIN_NEEDED, ERR_ALREADY_ARMED, + ERR_ALREADY_DISARMED, + ERR_CHALLENGE_NOT_SETUP, + ERR_FUNCTION_NOT_SUPPORTED, + ERR_NOT_SUPPORTED, + ERR_VALUE_OUT_OF_RANGE, ) -from .error import SmartHomeError, ChallengeNeeded +from .error import ChallengeNeeded, SmartHomeError _LOGGER = logging.getLogger(__name__)