Use quickplay when casting splash for mediaplayer.turn_on (#69866)

This commit is contained in:
Erik Montnemery 2022-04-12 19:06:25 +02:00 committed by GitHub
parent 80ff1ecb2a
commit 1645ab25a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View file

@ -456,7 +456,8 @@ class CastMediaPlayerEntity(CastDevice, MediaPlayerEntity):
# The only way we can turn the Chromecast is on is by launching an app
if self._chromecast.cast_type == pychromecast.const.CAST_TYPE_CHROMECAST:
self._chromecast.play_media(CAST_SPLASH, "image/png")
app_data = {"media_id": CAST_SPLASH, "media_type": "image/png"}
quick_play(self._chromecast, "default_media_receiver", app_data)
else:
self._chromecast.start_app(pychromecast.config.APP_MEDIA_RECEIVER)

View file

@ -1157,7 +1157,7 @@ async def test_entity_media_content_type(hass: HomeAssistant):
assert state.attributes.get("media_content_type") == "movie"
async def test_entity_control(hass: HomeAssistant):
async def test_entity_control(hass: HomeAssistant, quick_play_mock):
"""Test various device and media controls."""
entity_id = "media_player.speaker"
reg = er.async_get(hass)
@ -1200,8 +1200,13 @@ async def test_entity_control(hass: HomeAssistant):
# Turn on
await common.async_turn_on(hass, entity_id)
chromecast.play_media.assert_called_once_with(
"https://www.home-assistant.io/images/cast/splash.png", "image/png"
quick_play_mock.assert_called_once_with(
chromecast,
"default_media_receiver",
{
"media_id": "https://www.home-assistant.io/images/cast/splash.png",
"media_type": "image/png",
},
)
chromecast.quit_app.reset_mock()