From c40e32f06acab6c6549bcb2b49c18af03d288fc1 Mon Sep 17 00:00:00 2001 From: madmurl0c Date: Thu, 21 Apr 2022 14:21:55 +0000 Subject: [PATCH] Show volume next to state --- src/cards/media-player-card/utils.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cards/media-player-card/utils.ts b/src/cards/media-player-card/utils.ts index f6cd51d82..89ae0f6d4 100644 --- a/src/cards/media-player-card/utils.ts +++ b/src/cards/media-player-card/utils.ts @@ -49,8 +49,16 @@ export function computeMediaStateDisplay( hass: HomeAssistant ): string { let state = computeStateDisplay(hass.localize, entity, hass.locale); - if (![UNAVAILABLE, UNKNOWN, OFF].includes(entity.state) && config.use_media_info) { - return computeMediaDescription(entity) || state; + if (![UNAVAILABLE, UNKNOWN, OFF].includes(entity.state)) { + const volume = getVolumeLevel(entity); + if (volume !== undefined) { + state = `${state} - ${Math.round(volume)}%`; + } + if (config.use_media_info) { + return computeMediaDescription(entity) || state; + } else { + return state; + } } return state; }