Remove timeout from Russound RIO initialization (#134070)

This commit is contained in:
Noah Husby 2024-12-27 05:01:10 -05:00 committed by GitHub
parent b6afbe4b29
commit ad89004189
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 17 deletions

View File

@ -1,6 +1,5 @@
"""The russound_rio component."""
import asyncio
import logging
from aiorussound import RussoundClient, RussoundTcpConnectionHandler
@ -11,7 +10,7 @@ from homeassistant.const import CONF_HOST, CONF_PORT, Platform
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady
from .const import CONNECT_TIMEOUT, DOMAIN, RUSSOUND_RIO_EXCEPTIONS
from .const import DOMAIN, RUSSOUND_RIO_EXCEPTIONS
PLATFORMS = [Platform.MEDIA_PLAYER]
@ -40,8 +39,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: RussoundConfigEntry) ->
await client.register_state_update_callbacks(_connection_update_callback)
try:
async with asyncio.timeout(CONNECT_TIMEOUT):
await client.connect()
await client.connect()
except RUSSOUND_RIO_EXCEPTIONS as err:
raise ConfigEntryNotReady(
translation_domain=DOMAIN,

View File

@ -2,7 +2,6 @@
from __future__ import annotations
import asyncio
import logging
from typing import Any
@ -17,7 +16,7 @@ from homeassistant.config_entries import (
from homeassistant.const import CONF_HOST, CONF_PORT
from homeassistant.helpers import config_validation as cv
from .const import CONNECT_TIMEOUT, DOMAIN, RUSSOUND_RIO_EXCEPTIONS
from .const import DOMAIN, RUSSOUND_RIO_EXCEPTIONS
DATA_SCHEMA = vol.Schema(
{
@ -45,10 +44,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
client = RussoundClient(RussoundTcpConnectionHandler(host, port))
try:
async with asyncio.timeout(CONNECT_TIMEOUT):
await client.connect()
controller = client.controllers[1]
await client.disconnect()
await client.connect()
controller = client.controllers[1]
await client.disconnect()
except RUSSOUND_RIO_EXCEPTIONS:
_LOGGER.exception("Could not connect to Russound RIO")
errors["base"] = "cannot_connect"
@ -90,10 +88,9 @@ class FlowHandler(ConfigFlow, domain=DOMAIN):
# Connection logic is repeated here since this method will be removed in future releases
client = RussoundClient(RussoundTcpConnectionHandler(host, port))
try:
async with asyncio.timeout(CONNECT_TIMEOUT):
await client.connect()
controller = client.controllers[1]
await client.disconnect()
await client.connect()
controller = client.controllers[1]
await client.disconnect()
except RUSSOUND_RIO_EXCEPTIONS:
_LOGGER.exception("Could not connect to Russound RIO")
return self.async_abort(

View File

@ -16,9 +16,6 @@ RUSSOUND_RIO_EXCEPTIONS = (
asyncio.CancelledError,
)
CONNECT_TIMEOUT = 15
MP_FEATURES_BY_FLAG = {
FeatureFlag.COMMANDS_ZONE_MUTE_OFF_ON: MediaPlayerEntityFeature.VOLUME_MUTE
}