Add dynamic media player features to Russound (#122475)

Add dynamic media player features
This commit is contained in:
Noah Husby 2024-07-23 12:37:24 -04:00 committed by GitHub
parent 0a62a4459f
commit d78327a72f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -3,6 +3,9 @@
import asyncio import asyncio
from aiorussound import CommandException from aiorussound import CommandException
from aiorussound.const import FeatureFlag
from homeassistant.components.media_player import MediaPlayerEntityFeature
DOMAIN = "russound_rio" DOMAIN = "russound_rio"
@ -19,3 +22,7 @@ class NoPrimaryControllerException(Exception):
CONNECT_TIMEOUT = 5 CONNECT_TIMEOUT = 5
MP_FEATURES_BY_FLAG = {
FeatureFlag.COMMANDS_ZONE_MUTE_OFF_ON: MediaPlayerEntityFeature.VOLUME_MUTE
}

View File

@ -23,7 +23,7 @@ from homeassistant.helpers.issue_registry import IssueSeverity, async_create_iss
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import RussoundConfigEntry from . import RussoundConfigEntry
from .const import DOMAIN from .const import DOMAIN, MP_FEATURES_BY_FLAG
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -115,8 +115,7 @@ class RussoundZoneDevice(MediaPlayerEntity):
_attr_should_poll = False _attr_should_poll = False
_attr_has_entity_name = True _attr_has_entity_name = True
_attr_supported_features = ( _attr_supported_features = (
MediaPlayerEntityFeature.VOLUME_MUTE MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.VOLUME_SET
| MediaPlayerEntityFeature.TURN_ON | MediaPlayerEntityFeature.TURN_ON
| MediaPlayerEntityFeature.TURN_OFF | MediaPlayerEntityFeature.TURN_OFF
| MediaPlayerEntityFeature.SELECT_SOURCE | MediaPlayerEntityFeature.SELECT_SOURCE
@ -143,6 +142,9 @@ class RussoundZoneDevice(MediaPlayerEntity):
DOMAIN, DOMAIN,
self._controller.parent_controller.mac_address, 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): def _callback_handler(self, device_str, *args):
if ( if (