mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Don't override pychromecast MediaController's APP ID (#61796)
This commit is contained in:
parent
a371d568c0
commit
f17164fa47
@ -47,7 +47,6 @@ 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_LOVELACE,
|
||||
CAST_APP_ID_HOMEASSISTANT_MEDIA,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
STATE_IDLE,
|
||||
STATE_OFF,
|
||||
@ -230,7 +229,6 @@ class CastDevice(MediaPlayerEntity):
|
||||
self._cast_info.cast_info,
|
||||
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:
|
||||
@ -527,9 +525,8 @@ class CastDevice(MediaPlayerEntity):
|
||||
self._chromecast.register_handler(controller)
|
||||
controller.play_media(media)
|
||||
else:
|
||||
self._chromecast.media_controller.play_media(
|
||||
media_id, media_type, **kwargs.get(ATTR_MEDIA_EXTRA, {})
|
||||
)
|
||||
app_data = {"media_id": media_id, "media_type": media_type, **extra}
|
||||
quick_play(self._chromecast, "homeassistant_media", app_data)
|
||||
|
||||
def _media_status(self):
|
||||
"""
|
||||
@ -820,7 +817,6 @@ class DynamicCastGroup:
|
||||
self._cast_info.cast_info,
|
||||
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:
|
||||
|
@ -754,7 +754,7 @@ async def test_supported_features(
|
||||
assert state.attributes.get("supported_features") == supported_features
|
||||
|
||||
|
||||
async def test_entity_play_media(hass: HomeAssistant):
|
||||
async def test_entity_play_media(hass: HomeAssistant, quick_play_mock):
|
||||
"""Test playing media."""
|
||||
entity_id = "media_player.speaker"
|
||||
reg = er.async_get(hass)
|
||||
@ -776,8 +776,28 @@ async def test_entity_play_media(hass: HomeAssistant):
|
||||
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
|
||||
|
||||
# Play_media
|
||||
await common.async_play_media(hass, "audio", "best.mp3", entity_id)
|
||||
chromecast.media_controller.play_media.assert_called_once_with("best.mp3", "audio")
|
||||
await hass.services.async_call(
|
||||
media_player.DOMAIN,
|
||||
media_player.SERVICE_PLAY_MEDIA,
|
||||
{
|
||||
ATTR_ENTITY_ID: entity_id,
|
||||
media_player.ATTR_MEDIA_CONTENT_TYPE: "audio",
|
||||
media_player.ATTR_MEDIA_CONTENT_ID: "best.mp3",
|
||||
media_player.ATTR_MEDIA_EXTRA: {"metadata": {"metadatatype": 3}},
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
|
||||
chromecast.media_controller.play_media.assert_not_called()
|
||||
quick_play_mock.assert_called_once_with(
|
||||
chromecast,
|
||||
"homeassistant_media",
|
||||
{
|
||||
"media_id": "best.mp3",
|
||||
"media_type": "audio",
|
||||
"metadata": {"metadatatype": 3},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
async def test_entity_play_media_cast(hass: HomeAssistant, quick_play_mock):
|
||||
@ -865,7 +885,7 @@ async def test_entity_play_media_cast_invalid(hass, caplog, quick_play_mock):
|
||||
assert "App unknown not supported" in caplog.text
|
||||
|
||||
|
||||
async def test_entity_play_media_sign_URL(hass: HomeAssistant):
|
||||
async def test_entity_play_media_sign_URL(hass: HomeAssistant, quick_play_mock):
|
||||
"""Test playing media."""
|
||||
entity_id = "media_player.speaker"
|
||||
|
||||
@ -886,8 +906,10 @@ async def test_entity_play_media_sign_URL(hass: HomeAssistant):
|
||||
|
||||
# Play_media
|
||||
await common.async_play_media(hass, "audio", "/best.mp3", entity_id)
|
||||
chromecast.media_controller.play_media.assert_called_once_with(ANY, "audio")
|
||||
assert chromecast.media_controller.play_media.call_args[0][0].startswith(
|
||||
quick_play_mock.assert_called_once_with(
|
||||
chromecast, "homeassistant_media", {"media_id": ANY, "media_type": "audio"}
|
||||
)
|
||||
assert quick_play_mock.call_args[0][2]["media_id"].startswith(
|
||||
"http://example.com:8123/best.mp3?authSig="
|
||||
)
|
||||
|
||||
@ -1231,7 +1253,7 @@ async def test_group_media_states(hass, mz_mock):
|
||||
assert state.state == "playing"
|
||||
|
||||
|
||||
async def test_group_media_control(hass, mz_mock):
|
||||
async def test_group_media_control(hass, mz_mock, quick_play_mock):
|
||||
"""Test media controls are handled by group if entity has no state."""
|
||||
entity_id = "media_player.speaker"
|
||||
reg = er.async_get(hass)
|
||||
@ -1286,7 +1308,12 @@ async def test_group_media_control(hass, mz_mock):
|
||||
# Verify play_media is not forwarded
|
||||
await common.async_play_media(hass, "music", "best.mp3", entity_id)
|
||||
assert not grp_media.play_media.called
|
||||
assert chromecast.media_controller.play_media.called
|
||||
assert not chromecast.media_controller.play_media.called
|
||||
quick_play_mock.assert_called_once_with(
|
||||
chromecast,
|
||||
"homeassistant_media",
|
||||
{"media_id": "best.mp3", "media_type": "music"},
|
||||
)
|
||||
|
||||
|
||||
async def test_failed_cast_on_idle(hass, caplog):
|
||||
|
Loading…
x
Reference in New Issue
Block a user