Clean up Alexa smart home code (#24514)
* Clean up Alexa smart home code * lint * Lint * Lint
This commit is contained in:
1 parent
416ff10ba9
commit
7e2278f1cc
23 files changed
+3132
-2776
No files matched your search
@@ -4,7 +4,7 @@ import logging
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||
from homeassistant.components.alexa import smart_home as alexa_sh
|
||||
from homeassistant.components.alexa import const as alexa_const
|
||||
from homeassistant.components.google_assistant import const as ga_c
|
||||
from homeassistant.const import (
|
||||
CONF_MODE, CONF_NAME, CONF_REGION, EVENT_HOMEASSISTANT_START,
|
||||
@@ -33,9 +33,9 @@ SERVICE_REMOTE_DISCONNECT = 'remote_disconnect'
|
||||
|
||||
|
||||
ALEXA_ENTITY_SCHEMA = vol.Schema({
|
||||
vol.Optional(alexa_sh.CONF_DESCRIPTION): cv.string,
|
||||
vol.Optional(alexa_sh.CONF_DISPLAY_CATEGORIES): cv.string,
|
||||
vol.Optional(alexa_sh.CONF_NAME): cv.string,
|
||||
vol.Optional(alexa_const.CONF_DESCRIPTION): cv.string,
|
||||
vol.Optional(alexa_const.CONF_DISPLAY_CATEGORIES): cv.string,
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
})
|
||||
|
||||
GOOGLE_ENTITY_SCHEMA = vol.Schema({
|
||||
|
||||
@@ -7,7 +7,10 @@ import aiohttp
|
||||
from hass_nabucasa.client import CloudClient as Interface
|
||||
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.alexa import smart_home as alexa_sh
|
||||
from homeassistant.components.alexa import (
|
||||
config as alexa_config,
|
||||
smart_home as alexa_sh,
|
||||
)
|
||||
from homeassistant.components.google_assistant import (
|
||||
helpers as ga_h, smart_home as ga)
|
||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||
@@ -28,12 +31,12 @@ class CloudClient(Interface):
|
||||
|
||||
def __init__(self, hass: HomeAssistantType, prefs: CloudPreferences,
|
||||
websession: aiohttp.ClientSession,
|
||||
alexa_config: Dict[str, Any], google_config: Dict[str, Any]):
|
||||
alexa_cfg: Dict[str, Any], google_config: Dict[str, Any]):
|
||||
"""Initialize client interface to Cloud."""
|
||||
self._hass = hass
|
||||
self._prefs = prefs
|
||||
self._websession = websession
|
||||
self._alexa_user_config = alexa_config
|
||||
self._alexa_user_config = alexa_cfg
|
||||
self._google_user_config = google_config
|
||||
|
||||
self._alexa_config = None
|
||||
@@ -75,12 +78,12 @@ class CloudClient(Interface):
|
||||
return self._prefs.remote_enabled
|
||||
|
||||
@property
|
||||
def alexa_config(self) -> alexa_sh.Config:
|
||||
def alexa_config(self) -> alexa_config.Config:
|
||||
"""Return Alexa config."""
|
||||
if not self._alexa_config:
|
||||
alexa_conf = self._alexa_user_config
|
||||
|
||||
self._alexa_config = alexa_sh.Config(
|
||||
self._alexa_config = alexa_config.Config(
|
||||
endpoint=None,
|
||||
async_get_access_token=None,
|
||||
should_expose=alexa_conf[CONF_FILTER],
|
||||
|
||||
@@ -13,7 +13,7 @@ from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.components.http.data_validator import (
|
||||
RequestDataValidator)
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.components.alexa import smart_home as alexa_sh
|
||||
from homeassistant.components.alexa import entities as alexa_entities
|
||||
from homeassistant.components.google_assistant import helpers as google_helpers
|
||||
|
||||
from .const import (
|
||||
@@ -421,7 +421,7 @@ def _account_data(cloud):
|
||||
'prefs': client.prefs.as_dict(),
|
||||
'google_entities': client.google_user_config['filter'].config,
|
||||
'alexa_entities': client.alexa_config.should_expose.config,
|
||||
'alexa_domains': list(alexa_sh.ENTITY_ADAPTERS),
|
||||
'alexa_domains': list(alexa_entities.ENTITY_ADAPTERS),
|
||||
'remote_domain': remote.instance_domain,
|
||||
'remote_connected': remote.is_connected,
|
||||
'remote_certificate': certificate,
|
||||
@@ -497,7 +497,7 @@ async def google_assistant_list(hass, connection, msg):
|
||||
vol.Optional('disable_2fa'): bool,
|
||||
})
|
||||
async def google_assistant_update(hass, connection, msg):
|
||||
"""List all google assistant entities."""
|
||||
"""Update google assistant config."""
|
||||
cloud = hass.data[DOMAIN]
|
||||
changes = dict(msg)
|
||||
changes.pop('type')
|
||||
|
||||
Reference in new issue
Block a user