mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Add source zone exclusion to Russound RIO (#130392)
* Add source zone exclusion to Russound RIO * Ruff format
This commit is contained in:
parent
839f06b2dc
commit
d79dc8d22f
@ -5,8 +5,10 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from aiorussound import Controller
|
from aiorussound import Controller
|
||||||
|
from aiorussound.const import FeatureFlag
|
||||||
from aiorussound.models import PlayStatus, Source
|
from aiorussound.models import PlayStatus, Source
|
||||||
from aiorussound.rio import ZoneControlSurface
|
from aiorussound.rio import ZoneControlSurface
|
||||||
|
from aiorussound.util import is_feature_supported
|
||||||
|
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
MediaPlayerDeviceClass,
|
MediaPlayerDeviceClass,
|
||||||
@ -155,7 +157,18 @@ class RussoundZoneDevice(RussoundBaseEntity, MediaPlayerEntity):
|
|||||||
@property
|
@property
|
||||||
def source_list(self) -> list[str]:
|
def source_list(self) -> list[str]:
|
||||||
"""Return a list of available input sources."""
|
"""Return a list of available input sources."""
|
||||||
return [x.name for x in self._sources.values()]
|
available_sources = (
|
||||||
|
[
|
||||||
|
source
|
||||||
|
for source_id, source in self._sources.items()
|
||||||
|
if source_id in self._zone.enabled_sources
|
||||||
|
]
|
||||||
|
if is_feature_supported(
|
||||||
|
self._client.rio_version, FeatureFlag.SUPPORT_ZONE_SOURCE_EXCLUSION
|
||||||
|
)
|
||||||
|
else self._sources.values()
|
||||||
|
)
|
||||||
|
return [x.name for x in available_sources]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self) -> str | None:
|
def media_title(self) -> str | None:
|
||||||
|
@ -11,7 +11,7 @@ import pytest
|
|||||||
from homeassistant.components.russound_rio.const import DOMAIN
|
from homeassistant.components.russound_rio.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
|
||||||
from .const import HARDWARE_MAC, HOST, MOCK_CONFIG, MODEL, PORT
|
from .const import API_VERSION, HARDWARE_MAC, HOST, MOCK_CONFIG, MODEL, PORT
|
||||||
|
|
||||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||||
|
|
||||||
@ -71,4 +71,6 @@ def mock_russound_client() -> Generator[AsyncMock]:
|
|||||||
client.connection_handler = RussoundTcpConnectionHandler(HOST, PORT)
|
client.connection_handler = RussoundTcpConnectionHandler(HOST, PORT)
|
||||||
client.is_connected = Mock(return_value=True)
|
client.is_connected = Mock(return_value=True)
|
||||||
client.unregister_state_update_callbacks.return_value = True
|
client.unregister_state_update_callbacks.return_value = True
|
||||||
|
client.rio_version = API_VERSION
|
||||||
|
|
||||||
yield client
|
yield client
|
||||||
|
@ -8,6 +8,7 @@ HOST = "127.0.0.1"
|
|||||||
PORT = 9621
|
PORT = 9621
|
||||||
MODEL = "MCA-C5"
|
MODEL = "MCA-C5"
|
||||||
HARDWARE_MAC = "00:11:22:33:44:55"
|
HARDWARE_MAC = "00:11:22:33:44:55"
|
||||||
|
API_VERSION = "1.08.00"
|
||||||
|
|
||||||
MOCK_CONFIG = {
|
MOCK_CONFIG = {
|
||||||
"host": HOST,
|
"host": HOST,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user