Increase august timeout and make failure to sync at startup non-fatal (#65281)
This commit is contained in:
parent
2f6bf08165
commit
8c9bd6e790
6 changed files with 54 additions and 13 deletions
|
@ -43,7 +43,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
return await async_setup_august(hass, entry, august_gateway)
|
return await async_setup_august(hass, entry, august_gateway)
|
||||||
except (RequireValidation, InvalidAuth) as err:
|
except (RequireValidation, InvalidAuth) as err:
|
||||||
raise ConfigEntryAuthFailed from err
|
raise ConfigEntryAuthFailed from err
|
||||||
except (ClientResponseError, CannotConnect, asyncio.TimeoutError) as err:
|
except asyncio.TimeoutError as err:
|
||||||
|
raise ConfigEntryNotReady("Timed out connecting to august api") from err
|
||||||
|
except (ClientResponseError, CannotConnect) as err:
|
||||||
raise ConfigEntryNotReady from err
|
raise ConfigEntryNotReady from err
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,15 +143,34 @@ class AugustData(AugustSubscriberMixin):
|
||||||
self._pubnub_unsub = async_create_pubnub(user_data["UserID"], pubnub)
|
self._pubnub_unsub = async_create_pubnub(user_data["UserID"], pubnub)
|
||||||
|
|
||||||
if self._locks_by_id:
|
if self._locks_by_id:
|
||||||
tasks = []
|
# Do not prevent setup as the sync can timeout
|
||||||
for lock_id in self._locks_by_id:
|
# but it is not a fatal error as the lock
|
||||||
detail = self._device_detail_by_id[lock_id]
|
# will recover automatically when it comes back online.
|
||||||
tasks.append(
|
asyncio.create_task(self._async_initial_sync())
|
||||||
self.async_status_async(
|
|
||||||
lock_id, bool(detail.bridge and detail.bridge.hyper_bridge)
|
async def _async_initial_sync(self):
|
||||||
)
|
"""Attempt to request an initial sync."""
|
||||||
|
# We don't care if this fails because we only want to wake
|
||||||
|
# locks that are actually online anyways and they will be
|
||||||
|
# awake when they come back online
|
||||||
|
for result in await asyncio.gather(
|
||||||
|
*[
|
||||||
|
self.async_status_async(
|
||||||
|
device_id, bool(detail.bridge and detail.bridge.hyper_bridge)
|
||||||
|
)
|
||||||
|
for device_id, detail in self._device_detail_by_id.items()
|
||||||
|
if device_id in self._locks_by_id
|
||||||
|
],
|
||||||
|
return_exceptions=True,
|
||||||
|
):
|
||||||
|
if isinstance(result, Exception) and not isinstance(
|
||||||
|
result, (asyncio.TimeoutError, ClientResponseError, CannotConnect)
|
||||||
|
):
|
||||||
|
_LOGGER.warning(
|
||||||
|
"Unexpected exception during initial sync: %s",
|
||||||
|
result,
|
||||||
|
exc_info=result,
|
||||||
)
|
)
|
||||||
await asyncio.gather(*tasks)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_pubnub_message(self, device_id, date_time, message):
|
def async_pubnub_message(self, device_id, date_time, message):
|
||||||
|
|
|
@ -4,7 +4,7 @@ from datetime import timedelta
|
||||||
|
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
|
|
||||||
DEFAULT_TIMEOUT = 10
|
DEFAULT_TIMEOUT = 15
|
||||||
|
|
||||||
CONF_ACCESS_TOKEN_CACHE_FILE = "access_token_cache_file"
|
CONF_ACCESS_TOKEN_CACHE_FILE = "access_token_cache_file"
|
||||||
CONF_LOGIN_METHOD = "login_method"
|
CONF_LOGIN_METHOD = "login_method"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"domain": "august",
|
"domain": "august",
|
||||||
"name": "August",
|
"name": "August",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/august",
|
"documentation": "https://www.home-assistant.io/integrations/august",
|
||||||
"requirements": ["yalexs==1.1.19"],
|
"requirements": ["yalexs==1.1.20"],
|
||||||
"codeowners": ["@bdraco"],
|
"codeowners": ["@bdraco"],
|
||||||
"dhcp": [
|
"dhcp": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2513,7 +2513,7 @@ xs1-api-client==3.0.0
|
||||||
yalesmartalarmclient==0.3.7
|
yalesmartalarmclient==0.3.7
|
||||||
|
|
||||||
# homeassistant.components.august
|
# homeassistant.components.august
|
||||||
yalexs==1.1.19
|
yalexs==1.1.20
|
||||||
|
|
||||||
# homeassistant.components.yeelight
|
# homeassistant.components.yeelight
|
||||||
yeelight==0.7.8
|
yeelight==0.7.8
|
||||||
|
|
|
@ -1544,7 +1544,7 @@ xmltodict==0.12.0
|
||||||
yalesmartalarmclient==0.3.7
|
yalesmartalarmclient==0.3.7
|
||||||
|
|
||||||
# homeassistant.components.august
|
# homeassistant.components.august
|
||||||
yalexs==1.1.19
|
yalexs==1.1.20
|
||||||
|
|
||||||
# homeassistant.components.yeelight
|
# homeassistant.components.yeelight
|
||||||
yeelight==0.7.8
|
yeelight==0.7.8
|
||||||
|
|
|
@ -30,6 +30,26 @@ from tests.components.august.mocks import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_august_api_is_failing(hass):
|
||||||
|
"""Config entry state is SETUP_RETRY when august api is failing."""
|
||||||
|
|
||||||
|
config_entry = MockConfigEntry(
|
||||||
|
domain=DOMAIN,
|
||||||
|
data=_mock_get_config()[DOMAIN],
|
||||||
|
title="August august",
|
||||||
|
)
|
||||||
|
config_entry.add_to_hass(hass)
|
||||||
|
|
||||||
|
with patch(
|
||||||
|
"yalexs.authenticator_async.AuthenticatorAsync.async_authenticate",
|
||||||
|
side_effect=ClientResponseError(None, None, status=500),
|
||||||
|
):
|
||||||
|
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
assert config_entry.state is ConfigEntryState.SETUP_RETRY
|
||||||
|
|
||||||
|
|
||||||
async def test_august_is_offline(hass):
|
async def test_august_is_offline(hass):
|
||||||
"""Config entry state is SETUP_RETRY when august is offline."""
|
"""Config entry state is SETUP_RETRY when august is offline."""
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue