Improve Alexa error handling (#24745)

This commit is contained in:
Paulus Schoutsen 2019-06-24 22:04:31 -07:00 committed by GitHub
parent d4fc22add4
commit f5f86993f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 9 deletions

View file

@ -12,7 +12,10 @@ from homeassistant.components.google_assistant import smart_home as ga
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.util.aiohttp import MockRequest
from homeassistant.components.alexa import smart_home as alexa_sh
from homeassistant.components.alexa import (
smart_home as alexa_sh,
errors as alexa_errors,
)
from . import utils, alexa_config, google_config
from .const import DISPATCHER_REMOTE_UPDATE
@ -98,8 +101,14 @@ class CloudClient(Interface):
"""Initialize the client."""
self.cloud = cloud
if self.alexa_config.should_report_state and self.cloud.is_logged_in:
if (not self.alexa_config.should_report_state or
not self.cloud.is_logged_in):
return
try:
await self.alexa_config.async_enable_proactive_mode()
except alexa_errors.NoTokenAvailable:
pass
async def cleanups(self) -> None:
"""Cleanup some stuff after logout."""