Ensure tesla setup is retried on timeout (#50202)

This commit is contained in:
J. Nick Koston 2021-05-06 19:58:44 -05:00 committed by GitHub
parent 623a9c99fe
commit 89811fcbaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,7 @@ from homeassistant.const import (
HTTP_UNAUTHORIZED, HTTP_UNAUTHORIZED,
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.exceptions import ConfigEntryAuthFailed from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.httpx_client import SERVER_SOFTWARE, USER_AGENT from homeassistant.helpers.httpx_client import SERVER_SOFTWARE, USER_AGENT
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
@ -170,6 +170,9 @@ async def async_setup_entry(hass, config_entry):
except IncompleteCredentials as ex: except IncompleteCredentials as ex:
await async_client.aclose() await async_client.aclose()
raise ConfigEntryAuthFailed from ex raise ConfigEntryAuthFailed from ex
except httpx.ConnectTimeout as ex:
await async_client.aclose()
raise ConfigEntryNotReady from ex
except TeslaException as ex: except TeslaException as ex:
await async_client.aclose() await async_client.aclose()
if ex.code == HTTP_UNAUTHORIZED: if ex.code == HTTP_UNAUTHORIZED: