Skip to content

Commit

Permalink
Show volume next to state
Browse files Browse the repository at this point in the history
  • Loading branch information
madmurl0c committed Apr 21, 2022
1 parent 750148b commit c40e32f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/cards/media-player-card/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c40e32f

Please sign in to comment.