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]
|
||||
|
||||
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:
|
||||
"""Set up a config entry for Apple TV."""
|
||||
|
@ -64,27 +83,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
|
||||
try:
|
||||
await manager.async_first_connect()
|
||||
except (
|
||||
exceptions.AuthenticationError,
|
||||
exceptions.InvalidCredentialsError,
|
||||
exceptions.NoCredentialsError,
|
||||
) as ex:
|
||||
except AUTH_EXCEPTIONS as ex:
|
||||
raise ConfigEntryAuthFailed(
|
||||
f"{address}: Authentication failed, try reconfiguring device: {ex}"
|
||||
) from ex
|
||||
except (
|
||||
asyncio.CancelledError,
|
||||
exceptions.ConnectionLostError,
|
||||
exceptions.ConnectionFailedError,
|
||||
) as ex:
|
||||
except CONNECTION_TIMEOUT_EXCEPTIONS as ex:
|
||||
raise ConfigEntryNotReady(f"{address}: {ex}") from ex
|
||||
except (
|
||||
exceptions.ProtocolError,
|
||||
exceptions.NoServiceError,
|
||||
exceptions.PairingError,
|
||||
exceptions.BackOffError,
|
||||
exceptions.DeviceIdMissingError,
|
||||
) as ex:
|
||||
except DEVICE_EXCEPTIONS as ex:
|
||||
_LOGGER.debug(
|
||||
"Error setting up apple_tv at %s: %s", address, ex, exc_info=ex
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue