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 GitHub
parent 89807f0d2d
commit 1a2a3b5955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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 (