Fix comments, improve readability in Cloud (#64291)

This commit is contained in:
Erik Montnemery 2022-01-17 14:19:11 +01:00 committed by GitHub
parent b45f3b97c3
commit aa40476b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 16 deletions

View File

@ -13,7 +13,7 @@ from hass_nabucasa.client import CloudClient as Interface
from homeassistant.components import persistent_notification, webhook
from homeassistant.components.alexa import (
errors as alexa_errors,
smart_home as alexa_sh,
smart_home as alexa_smart_home,
)
from homeassistant.components.google_assistant import const as gc, smart_home as ga
from homeassistant.core import Context, HomeAssistant, callback
@ -180,7 +180,7 @@ class CloudClient(Interface):
"""Process cloud alexa message to client."""
cloud_user = await self._prefs.get_cloud_user()
aconfig = await self.get_alexa_config()
return await alexa_sh.async_handle_message(
return await alexa_smart_home.async_handle_message(
self._hass,
aconfig,
payload,

View File

@ -88,7 +88,7 @@ class CloudGoogleConfig(AbstractConfig):
start.async_at_start(self.hass, hass_started)
# Remove old/wrong user agent ids
# Remove any stored user agent id that is not ours
remove_agent_user_ids = []
for agent_user_id in self._store.agent_user_ids:
if agent_user_id != self.agent_user_id:

View File

@ -434,17 +434,17 @@ async def _account_data(cloud):
certificate = None
return {
"logged_in": True,
"email": claims["email"],
"cloud": cloud.iot.state,
"prefs": client.prefs.as_dict(),
"google_registered": google_config.has_registered_user_agent,
"google_entities": client.google_user_config["filter"].config,
"alexa_registered": alexa_config.authorized,
"alexa_entities": client.alexa_user_config["filter"].config,
"remote_domain": remote.instance_domain,
"remote_connected": remote.is_connected,
"alexa_registered": alexa_config.authorized,
"cloud": cloud.iot.state,
"email": claims["email"],
"google_entities": client.google_user_config["filter"].config,
"google_registered": google_config.has_registered_user_agent,
"logged_in": True,
"prefs": client.prefs.as_dict(),
"remote_certificate": certificate,
"remote_connected": remote.is_connected,
"remote_domain": remote.instance_domain,
}

View File

@ -275,7 +275,7 @@ class CloudPreferences:
return self._prefs.get(PREF_TTS_DEFAULT_VOICE, DEFAULT_TTS_DEFAULT_VOICE)
async def get_cloud_user(self) -> str:
"""Return ID from Home Assistant Cloud system user."""
"""Return ID of Home Assistant Cloud system user."""
user = await self._load_cloud_user()
if user:

View File

@ -256,16 +256,19 @@ class AbstractConfig(ABC):
raise NotImplementedError
async def async_connect_agent_user(self, agent_user_id: str):
"""Add an synced and known agent_user_id.
"""Add a synced and known agent_user_id.
Called when a completed sync response have been sent to Google.
Called before sending a sync response to Google.
"""
self._store.add_agent_user_id(agent_user_id)
async def async_disconnect_agent_user(self, agent_user_id: str):
"""Turn off report state and disable further state reporting.
Called when the user disconnects their account from Google.
Called when:
- The user disconnects their account from Google.
- When the cloud configuration is initialized
- When sync entities fails with 404
"""
self._store.pop_agent_user_id(agent_user_id)