Ensure apple_tv setup retries later on timeout (#113367)
This commit is contained in:
parent
1abb448106
commit
e0828f1efc
1 changed files with 22 additions and 17 deletions
|
@ -54,6 +54,25 @@ SIGNAL_DISCONNECTED = "apple_tv_disconnected"
|
||||||
|
|
||||||
PLATFORMS = [Platform.MEDIA_PLAYER, Platform.REMOTE]
|
PLATFORMS = [Platform.MEDIA_PLAYER, Platform.REMOTE]
|
||||||
|
|
||||||
|
AUTH_EXCEPTIONS = (
|
||||||
|
exceptions.AuthenticationError,
|
||||||
|
exceptions.InvalidCredentialsError,
|
||||||
|
exceptions.NoCredentialsError,
|
||||||
|
)
|
||||||
|
CONNECTION_TIMEOUT_EXCEPTIONS = (
|
||||||
|
asyncio.CancelledError,
|
||||||
|
TimeoutError,
|
||||||
|
exceptions.ConnectionLostError,
|
||||||
|
exceptions.ConnectionFailedError,
|
||||||
|
)
|
||||||
|
DEVICE_EXCEPTIONS = (
|
||||||
|
exceptions.ProtocolError,
|
||||||
|
exceptions.NoServiceError,
|
||||||
|
exceptions.PairingError,
|
||||||
|
exceptions.BackOffError,
|
||||||
|
exceptions.DeviceIdMissingError,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up a config entry for Apple TV."""
|
"""Set up a config entry for Apple TV."""
|
||||||
|
@ -64,27 +83,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await manager.async_first_connect()
|
await manager.async_first_connect()
|
||||||
except (
|
except AUTH_EXCEPTIONS as ex:
|
||||||
exceptions.AuthenticationError,
|
|
||||||
exceptions.InvalidCredentialsError,
|
|
||||||
exceptions.NoCredentialsError,
|
|
||||||
) as ex:
|
|
||||||
raise ConfigEntryAuthFailed(
|
raise ConfigEntryAuthFailed(
|
||||||
f"{address}: Authentication failed, try reconfiguring device: {ex}"
|
f"{address}: Authentication failed, try reconfiguring device: {ex}"
|
||||||
) from ex
|
) from ex
|
||||||
except (
|
except CONNECTION_TIMEOUT_EXCEPTIONS as ex:
|
||||||
asyncio.CancelledError,
|
|
||||||
exceptions.ConnectionLostError,
|
|
||||||
exceptions.ConnectionFailedError,
|
|
||||||
) as ex:
|
|
||||||
raise ConfigEntryNotReady(f"{address}: {ex}") from ex
|
raise ConfigEntryNotReady(f"{address}: {ex}") from ex
|
||||||
except (
|
except DEVICE_EXCEPTIONS as ex:
|
||||||
exceptions.ProtocolError,
|
|
||||||
exceptions.NoServiceError,
|
|
||||||
exceptions.PairingError,
|
|
||||||
exceptions.BackOffError,
|
|
||||||
exceptions.DeviceIdMissingError,
|
|
||||||
) as ex:
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Error setting up apple_tv at %s: %s", address, ex, exc_info=ex
|
"Error setting up apple_tv at %s: %s", address, ex, exc_info=ex
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue