Skip to content

Commit

Permalink
Set source & sound mode at start in media player reproduce state (#70064
Browse files Browse the repository at this point in the history
)
  • Loading branch information
thecode authored Apr 15, 2022
1 parent 89807f0 commit 1a2a3b5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions homeassistant/components/media_player/reproduce_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,7 @@ async def call_service(service: str, keys: Iterable) -> None:
cur_state = hass.states.get(state.entity_id)
features = cur_state.attributes[ATTR_SUPPORTED_FEATURES] if cur_state else 0

if (
ATTR_MEDIA_VOLUME_LEVEL in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_SET
):
await call_service(SERVICE_VOLUME_SET, [ATTR_MEDIA_VOLUME_LEVEL])

if (
ATTR_MEDIA_VOLUME_MUTED in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_MUTE
):
await call_service(SERVICE_VOLUME_MUTE, [ATTR_MEDIA_VOLUME_MUTED])

# First set source & sound mode to match the saved supported features
if (
ATTR_INPUT_SOURCE in state.attributes
and features & MediaPlayerEntityFeature.SELECT_SOURCE
Expand All @@ -107,6 +96,18 @@ async def call_service(service: str, keys: Iterable) -> None:
):
await call_service(SERVICE_SELECT_SOUND_MODE, [ATTR_SOUND_MODE])

if (
ATTR_MEDIA_VOLUME_LEVEL in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_SET
):
await call_service(SERVICE_VOLUME_SET, [ATTR_MEDIA_VOLUME_LEVEL])

if (
ATTR_MEDIA_VOLUME_MUTED in state.attributes
and features & MediaPlayerEntityFeature.VOLUME_MUTE
):
await call_service(SERVICE_VOLUME_MUTE, [ATTR_MEDIA_VOLUME_MUTED])

already_playing = False

if (ATTR_MEDIA_CONTENT_TYPE in state.attributes) and (
Expand Down

0 comments on commit 1a2a3b5

Please sign in to comment.