Only lookup supported_features once in media_player capability_attributes (#96510)

This commit is contained in:
J. Nick Koston 2023-07-13 16:46:09 -10:00 committed by GitHub
parent c44c7bba84
commit 0e8c85c5fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1001,13 +1001,14 @@ class MediaPlayerEntity(Entity):
def capability_attributes(self) -> dict[str, Any]:
"""Return capability attributes."""
data: dict[str, Any] = {}
supported_features = self.supported_features
if self.supported_features & MediaPlayerEntityFeature.SELECT_SOURCE and (
if supported_features & MediaPlayerEntityFeature.SELECT_SOURCE and (
source_list := self.source_list
):
data[ATTR_INPUT_SOURCE_LIST] = source_list
if self.supported_features & MediaPlayerEntityFeature.SELECT_SOUND_MODE and (
if supported_features & MediaPlayerEntityFeature.SELECT_SOUND_MODE and (
sound_mode_list := self.sound_mode_list
):
data[ATTR_SOUND_MODE_LIST] = sound_mode_list