Make it possible to turn on audio only google cast devices (#62420)

This commit is contained in:
Erik Montnemery 2021-12-20 20:18:11 +01:00 committed by GitHub
parent 5a41251d45
commit a7a0cfd9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -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

View File

@ -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,
),