From d78327a72f495ea8d7af7f0cfd9d0d4bc8ea6616 Mon Sep 17 00:00:00 2001 From: Noah Husby <32528627+noahhusby@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:37:24 -0400 Subject: [PATCH] Add dynamic media player features to Russound (#122475) Add dynamic media player features --- homeassistant/components/russound_rio/const.py | 7 +++++++ homeassistant/components/russound_rio/media_player.py | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/russound_rio/const.py b/homeassistant/components/russound_rio/const.py index e5bf81e464a..d1f4e1c4c0e 100644 --- a/homeassistant/components/russound_rio/const.py +++ b/homeassistant/components/russound_rio/const.py @@ -3,6 +3,9 @@ import asyncio from aiorussound import CommandException +from aiorussound.const import FeatureFlag + +from homeassistant.components.media_player import MediaPlayerEntityFeature DOMAIN = "russound_rio" @@ -19,3 +22,7 @@ class NoPrimaryControllerException(Exception): CONNECT_TIMEOUT = 5 + +MP_FEATURES_BY_FLAG = { + FeatureFlag.COMMANDS_ZONE_MUTE_OFF_ON: MediaPlayerEntityFeature.VOLUME_MUTE +} diff --git a/homeassistant/components/russound_rio/media_player.py b/homeassistant/components/russound_rio/media_player.py index faec7ceff99..89ef68346c2 100644 --- a/homeassistant/components/russound_rio/media_player.py +++ b/homeassistant/components/russound_rio/media_player.py @@ -23,7 +23,7 @@ from homeassistant.helpers.issue_registry import IssueSeverity, async_create_iss from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from . import RussoundConfigEntry -from .const import DOMAIN +from .const import DOMAIN, MP_FEATURES_BY_FLAG _LOGGER = logging.getLogger(__name__) @@ -115,8 +115,7 @@ class RussoundZoneDevice(MediaPlayerEntity): _attr_should_poll = False _attr_has_entity_name = True _attr_supported_features = ( - MediaPlayerEntityFeature.VOLUME_MUTE - | MediaPlayerEntityFeature.VOLUME_SET + MediaPlayerEntityFeature.VOLUME_SET | MediaPlayerEntityFeature.TURN_ON | MediaPlayerEntityFeature.TURN_OFF | MediaPlayerEntityFeature.SELECT_SOURCE @@ -143,6 +142,9 @@ class RussoundZoneDevice(MediaPlayerEntity): DOMAIN, self._controller.parent_controller.mac_address, ) + for flag, feature in MP_FEATURES_BY_FLAG.items(): + if flag in zone.instance.supported_features: + self._attr_supported_features |= feature def _callback_handler(self, device_str, *args): if (