mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Ensure androidtv_remote does not block startup of HA (#96582)
* Ensure androidtv_remote does not block startup of HA * Fix lint * Use asyncio.wait_for * Update homeassistant/components/androidtv_remote/__init__.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Update homeassistant/components/androidtv_remote/__init__.py Co-authored-by: Erik Montnemery <erik@montnemery.com> * Fix lint * Lint * Update __init__.py --------- Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
5ffffd8dbc
commit
df19d4fd15
@ -1,6 +1,7 @@
|
||||
"""The Android TV Remote integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from androidtvremote2 import (
|
||||
@ -9,6 +10,7 @@ from androidtvremote2 import (
|
||||
ConnectionClosed,
|
||||
InvalidAuth,
|
||||
)
|
||||
import async_timeout
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, EVENT_HOMEASSISTANT_STOP, Platform
|
||||
@ -43,11 +45,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
api.add_is_available_updated_callback(is_available_updated)
|
||||
|
||||
try:
|
||||
await api.async_connect()
|
||||
async with async_timeout.timeout(5.0):
|
||||
await api.async_connect()
|
||||
except InvalidAuth as exc:
|
||||
# The Android TV is hard reset or the certificate and key files were deleted.
|
||||
raise ConfigEntryAuthFailed from exc
|
||||
except (CannotConnect, ConnectionClosed) as exc:
|
||||
except (CannotConnect, ConnectionClosed, asyncio.TimeoutError) as exc:
|
||||
# The Android TV is network unreachable. Raise exception and let Home Assistant retry
|
||||
# later. If device gets a new IP address the zeroconf flow will update the config.
|
||||
raise ConfigEntryNotReady from exc
|
||||
|
Loading…
x
Reference in New Issue
Block a user