Set source & sound mode at start in media player reproduce state (#70064)

This commit is contained in:
Shay Levy 2022-04-15 19:14:07 +03:00 committed by Franck Nijhof
parent 236acd6206
commit 0a6182264a
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3

View File

@ -83,18 +83,7 @@ async def _async_reproduce_states(
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
@ -107,6 +96,18 @@ async def _async_reproduce_states(
):
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 (