From 47b6755177b47b721cc077b4b182f2a2a491a785 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Wed, 10 Nov 2021 19:40:49 +0100 Subject: [PATCH] Google Cast: Use own media player app (#55524) --- homeassistant/components/cast/media_player.py | 3 +++ homeassistant/components/google_assistant/trait.py | 4 ++-- homeassistant/const.py | 8 +++++--- tests/components/google_assistant/test_smart_home.py | 2 +- tests/components/google_assistant/test_trait.py | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/cast/media_player.py b/homeassistant/components/cast/media_player.py index eca7c69f5d2..d8eacfeede4 100644 --- a/homeassistant/components/cast/media_player.py +++ b/homeassistant/components/cast/media_player.py @@ -46,6 +46,7 @@ from homeassistant.components.media_player.const import ( from homeassistant.components.plex.const import PLEX_URI_SCHEME from homeassistant.components.plex.services import lookup_plex_media from homeassistant.const import ( + CAST_APP_ID_HOMEASSISTANT_MEDIA, EVENT_HOMEASSISTANT_STOP, STATE_IDLE, STATE_OFF, @@ -244,6 +245,7 @@ class CastDevice(MediaPlayerEntity): ), ChromeCastZeroconf.get_zeroconf(), ) + chromecast.media_controller.app_id = CAST_APP_ID_HOMEASSISTANT_MEDIA self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: @@ -816,6 +818,7 @@ class DynamicCastGroup: ), ChromeCastZeroconf.get_zeroconf(), ) + chromecast.media_controller.app_id = CAST_APP_ID_HOMEASSISTANT_MEDIA self._chromecast = chromecast if CAST_MULTIZONE_MANAGER_KEY not in self.hass.data: diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index 9f79f0f7d9b..66df9315220 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -35,7 +35,7 @@ from homeassistant.const import ( ATTR_MODE, ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE, - CAST_APP_ID_HOMEASSISTANT, + CAST_APP_ID_HOMEASSISTANT_MEDIA, SERVICE_ALARM_ARM_AWAY, SERVICE_ALARM_ARM_CUSTOM_BYPASS, SERVICE_ALARM_ARM_HOME, @@ -307,7 +307,7 @@ class CameraStreamTrait(_Trait): ) self.stream_info = { "cameraStreamAccessUrl": f"{get_url(self.hass)}{url}", - "cameraStreamReceiverAppId": CAST_APP_ID_HOMEASSISTANT, + "cameraStreamReceiverAppId": CAST_APP_ID_HOMEASSISTANT_MEDIA, } diff --git a/homeassistant/const.py b/homeassistant/const.py index 2142556a217..4c8adb3426b 100644 --- a/homeassistant/const.py +++ b/homeassistant/const.py @@ -695,9 +695,6 @@ PRECISION_TENTHS: Final = 0.1 # cloud, alexa, or google_home components CLOUD_NEVER_EXPOSED_ENTITIES: Final[list[str]] = ["group.all_locks"] -# The ID of the Home Assistant Cast App -CAST_APP_ID_HOMEASSISTANT: Final = "B12CE3CA" - ENTITY_CATEGORY_CONFIG: Final = "config" ENTITY_CATEGORY_DIAGNOSTIC: Final = "diagnostic" ENTITY_CATEGORY_SYSTEM: Final = "system" @@ -710,3 +707,8 @@ ENTITY_CATEGORIES: Final[list[str]] = [ ENTITY_CATEGORY_DIAGNOSTIC, ENTITY_CATEGORY_SYSTEM, ] + +# The ID of the Home Assistant Media Player Cast App +CAST_APP_ID_HOMEASSISTANT_MEDIA: Final = "B45F4572" +# The ID of the Home Assistant Lovelace Cast App +CAST_APP_ID_HOMEASSISTANT_LOVELACE: Final = "A078F6B0" diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index 161b4a6f3cb..9d259290956 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -940,7 +940,7 @@ async def test_trait_execute_adding_query_data(hass): "states": { "online": True, "cameraStreamAccessUrl": "https://example.com/api/streams/bla", - "cameraStreamReceiverAppId": "B12CE3CA", + "cameraStreamReceiverAppId": "B45F4572", }, } ] diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index 290aa00bb47..62a9d7a0120 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -146,7 +146,7 @@ async def test_camera_stream(hass): assert trt.query_attributes() == { "cameraStreamAccessUrl": "https://example.com/api/streams/bla", - "cameraStreamReceiverAppId": "B12CE3CA", + "cameraStreamReceiverAppId": "B45F4572", }