From a7a0cfd9e672637d6957f52b4898302c35834090 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 20 Dec 2021 20:18:11 +0100 Subject: [PATCH] Make it possible to turn on audio only google cast devices (#62420) --- homeassistant/components/cast/media_player.py | 13 ++++++++----- tests/components/cast/test_media_player.py | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index b687f96948b..8160c1f5bf0 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -395,11 +395,14 @@ class CastDevice(MediaPlayerEntity): return if self._chromecast.app_id is not None: - # Quit the previous app before starting splash screen + # Quit the previous app before starting splash screen or media player self._chromecast.quit_app() # The only way we can turn the Chromecast is on is by launching an app - self._chromecast.play_media(CAST_SPLASH, pychromecast.STREAM_TYPE_BUFFERED) + if self._chromecast.cast_type == pychromecast.const.CAST_TYPE_CHROMECAST: + self._chromecast.play_media(CAST_SPLASH, pychromecast.STREAM_TYPE_BUFFERED) + else: + self._chromecast.start_app(pychromecast.config.APP_MEDIA_RECEIVER) def turn_off(self): """Turn off the cast device.""" @@ -674,9 +677,9 @@ class CastDevice(MediaPlayerEntity): support = SUPPORT_CAST media_status = self._media_status()[0] - if ( - self._chromecast - and self._chromecast.cast_type == pychromecast.const.CAST_TYPE_CHROMECAST + if self._chromecast and self._chromecast.cast_type in ( + pychromecast.const.CAST_TYPE_CHROMECAST, + pychromecast.const.CAST_TYPE_AUDIO, ): support |= SUPPORT_TURN_ON diff --git a/tests/components/cast/test_media_player.py b/tests/components/cast/test_media_player.py index dae9981ae67..3c5d4705713 100644 --- a/tests/components/cast/test_media_player.py +++ b/tests/components/cast/test_media_player.py @@ -683,10 +683,12 @@ async def test_entity_cast_status(hass: HomeAssistant): | SUPPORT_PLAY_MEDIA | SUPPORT_STOP | SUPPORT_TURN_OFF + | SUPPORT_TURN_ON | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, SUPPORT_PLAY_MEDIA | SUPPORT_TURN_OFF + | SUPPORT_TURN_ON | SUPPORT_VOLUME_MUTE | SUPPORT_VOLUME_SET, ),