Skip to content

Commit

Permalink
Remove timeout from Russound RIO initialization (home-assistant#134070)
Browse files Browse the repository at this point in the history
  • Loading branch information
noahhusby authored Dec 27, 2024
1 parent b6afbe4 commit ad89004
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
6 changes: 2 additions & 4 deletions homeassistant/components/russound_rio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""The russound_rio component."""

import asyncio
import logging

from aiorussound import RussoundClient, RussoundTcpConnectionHandler
Expand All @@ -11,7 +10,7 @@
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]

Expand Down Expand Up @@ -40,8 +39,7 @@ async def _connection_update_callback(
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,
Expand Down
17 changes: 7 additions & 10 deletions homeassistant/components/russound_rio/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from __future__ import annotations

import asyncio
import logging
from typing import Any

Expand All @@ -17,7 +16,7 @@
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(
{
Expand Down Expand Up @@ -45,10 +44,9 @@ async def async_step_user(

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"
Expand Down Expand Up @@ -90,10 +88,9 @@ async def async_step_import(self, import_data: dict[str, Any]) -> ConfigFlowResu
# 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(
Expand Down
3 changes: 0 additions & 3 deletions homeassistant/components/russound_rio/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
asyncio.CancelledError,
)


CONNECT_TIMEOUT = 15

MP_FEATURES_BY_FLAG = {
FeatureFlag.COMMANDS_ZONE_MUTE_OFF_ON: MediaPlayerEntityFeature.VOLUME_MUTE
}

0 comments on commit ad89004

Please sign in to comment.