Use pychromecast CastInfo type in cast integration (#60205)

This commit is contained in:
Erik Montnemery 2021-11-23 23:17:58 +01:00 committed by GitHub
parent 027577805e
commit 615198a58f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 149 additions and 194 deletions

View File

@ -26,12 +26,7 @@ def discover_chromecast(
"""Discover a Chromecast."""
info = ChromecastInfo(
services=cast_info.services,
uuid=cast_info.uuid,
model_name=cast_info.model_name,
friendly_name=cast_info.friendly_name,
cast_type=cast_info.cast_type,
manufacturer=cast_info.manufacturer,
cast_info=cast_info,
)
if info.uuid is None:
@ -76,12 +71,7 @@ def setup_internal_discovery(hass: HomeAssistant, config_entry) -> None:
_remove_chromecast(
hass,
ChromecastInfo(
services=cast_info.services,
uuid=cast_info.uuid,
model_name=cast_info.model_name,
friendly_name=cast_info.friendly_name,
cast_type=cast_info.cast_type,
manufacturer=cast_info.manufacturer,
cast_info=cast_info,
),
)

View File

@ -6,6 +6,7 @@ from typing import Optional
import attr
from pychromecast import dial
from pychromecast.const import CAST_TYPE_GROUP
from pychromecast.models import CastInfo
@attr.s(slots=True, frozen=True)
@ -15,18 +16,23 @@ class ChromecastInfo:
This also has the same attributes as the mDNS fields by zeroconf.
"""
services: set | None = attr.ib()
uuid: str = attr.ib(converter=attr.converters.optional(str))
model_name: str = attr.ib()
friendly_name: str = attr.ib()
cast_type: str = attr.ib()
manufacturer: str = attr.ib()
cast_info: CastInfo = attr.ib()
is_dynamic_group = attr.ib(type=Optional[bool], default=None)
@property
def friendly_name(self) -> str:
"""Return the UUID."""
return self.cast_info.friendly_name
@property
def is_audio_group(self) -> bool:
"""Return if the cast is an audio group."""
return self.cast_type == CAST_TYPE_GROUP
return self.cast_info.cast_type == CAST_TYPE_GROUP
@property
def uuid(self) -> bool:
"""Return the UUID."""
return self.cast_info.uuid
def fill_out_missing_chromecast_info(self) -> ChromecastInfo:
"""Return a new ChromecastInfo object with missing attributes filled in.
@ -42,21 +48,16 @@ class ChromecastInfo:
http_group_status = None
http_group_status = dial.get_multizone_status(
None,
services=self.services,
services=self.cast_info.services,
zconf=ChromeCastZeroconf.get_zeroconf(),
)
if http_group_status is not None:
is_dynamic_group = any(
str(g.uuid) == self.uuid for g in http_group_status.dynamic_groups
g.uuid == self.cast_info.uuid for g in http_group_status.dynamic_groups
)
return ChromecastInfo(
services=self.services,
uuid=self.uuid,
friendly_name=self.friendly_name,
model_name=self.model_name,
cast_type=self.cast_type,
manufacturer=self.manufacturer,
cast_info=self.cast_info,
is_dynamic_group=is_dynamic_group,
)

View File

@ -134,7 +134,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
"""Handle discovery of a new chromecast."""
# If wanted_uuids is set, we're only accepting specific cast devices identified
# by UUID
if wanted_uuids is not None and discover.uuid not in wanted_uuids:
if wanted_uuids is not None and str(discover.uuid) not in wanted_uuids:
# UUID not matching, ignore.
return
@ -162,7 +162,6 @@ class CastDevice(MediaPlayerEntity):
"""Initialize the cast device."""
self._cast_info = cast_info
self.services = cast_info.services
self._chromecast: pychromecast.Chromecast | None = None
self.cast_status = None
self.media_status = None
@ -176,13 +175,13 @@ class CastDevice(MediaPlayerEntity):
self._add_remove_handler = None
self._cast_view_remove_handler = None
self._attr_unique_id = cast_info.uuid
self._attr_unique_id = str(cast_info.uuid)
self._attr_name = cast_info.friendly_name
if cast_info.model_name != "Google Cast Group":
if cast_info.cast_info.model_name != "Google Cast Group":
self._attr_device_info = DeviceInfo(
identifiers={(CAST_DOMAIN, str(cast_info.uuid).replace("-", ""))},
manufacturer=str(cast_info.manufacturer),
model=cast_info.model_name,
manufacturer=str(cast_info.cast_info.manufacturer),
model=cast_info.cast_info.model_name,
name=str(cast_info.friendly_name),
)
@ -224,20 +223,11 @@ class CastDevice(MediaPlayerEntity):
"[%s %s] Connecting to cast device by service %s",
self.entity_id,
self._cast_info.friendly_name,
self.services,
self._cast_info.cast_info.services,
)
chromecast = await self.hass.async_add_executor_job(
pychromecast.get_chromecast_from_cast_info,
pychromecast.discovery.CastInfo(
self.services,
self._cast_info.uuid,
self._cast_info.model_name,
self._cast_info.friendly_name,
None,
None,
self._cast_info.cast_type,
self._cast_info.manufacturer,
),
self._cast_info.cast_info,
ChromeCastZeroconf.get_zeroconf(),
)
chromecast.media_controller.app_id = CAST_APP_ID_HOMEASSISTANT_MEDIA
@ -776,7 +766,6 @@ class DynamicCastGroup:
self.hass = hass
self._cast_info = cast_info
self.services = cast_info.services
self._chromecast: pychromecast.Chromecast | None = None
self.mz_mgr = None
self._status_listener: CastStatusListener | None = None
@ -824,20 +813,11 @@ class DynamicCastGroup:
"[%s %s] Connecting to cast device by service %s",
"Dynamic group",
self._cast_info.friendly_name,
self.services,
self._cast_info.cast_info.services,
)
chromecast = await self.hass.async_add_executor_job(
pychromecast.get_chromecast_from_cast_info,
pychromecast.discovery.CastInfo(
self.services,
self._cast_info.uuid,
self._cast_info.model_name,
self._cast_info.friendly_name,
None,
None,
self._cast_info.cast_type,
self._cast_info.manufacturer,
),
self._cast_info.cast_info,
ChromeCastZeroconf.get_zeroconf(),
)
chromecast.media_controller.app_id = CAST_APP_ID_HOMEASSISTANT_MEDIA
@ -889,7 +869,7 @@ class DynamicCastGroup:
# Removed is not our device.
return
if not discover.services:
if not discover.cast_info.services:
# Clean up the dynamic group
_LOGGER.debug("Clean up dynamic group: %s", discover)
await self.async_tear_down()

View File

@ -7,11 +7,11 @@ import pytest
@pytest.fixture()
def dial_mock():
def get_multizone_status_mock():
"""Mock pychromecast dial."""
dial_mock = MagicMock()
dial_mock.get_multizone_status.return_value.dynamic_groups = []
return dial_mock
mock = MagicMock(spec_set=pychromecast.dial.get_multizone_status)
mock.return_value.dynamic_groups = []
return mock
@pytest.fixture()
@ -23,7 +23,7 @@ def castbrowser_mock():
@pytest.fixture()
def mz_mock():
"""Mock pychromecast MultizoneManager."""
return MagicMock()
return MagicMock(spec_set=pychromecast.controllers.multizone.MultizoneManager)
@pytest.fixture()
@ -40,7 +40,11 @@ def get_chromecast_mock():
@pytest.fixture(autouse=True)
def cast_mock(
dial_mock, mz_mock, quick_play_mock, castbrowser_mock, get_chromecast_mock
mz_mock,
quick_play_mock,
castbrowser_mock,
get_chromecast_mock,
get_multizone_status_mock,
):
"""Mock pychromecast."""
ignore_cec_orig = list(pychromecast.IGNORE_CEC)
@ -48,7 +52,10 @@ def cast_mock(
with patch(
"homeassistant.components.cast.discovery.pychromecast.discovery.CastBrowser",
castbrowser_mock,
), patch("homeassistant.components.cast.helpers.dial", dial_mock), patch(
), patch(
"homeassistant.components.cast.helpers.dial.get_multizone_status",
get_multizone_status_mock,
), patch(
"homeassistant.components.cast.media_player.MultizoneManager",
return_value=mz_mock,
), patch(

View File

@ -67,40 +67,21 @@ def get_fake_chromecast_info(
):
"""Generate a Fake ChromecastInfo with the specified arguments."""
@attr.s(slots=True, frozen=True, eq=False)
class ExtendedChromecastInfo(ChromecastInfo):
host: str | None = attr.ib(default=None)
port: int | None = attr.ib(default=0)
def __eq__(self, other):
if isinstance(other, ChromecastInfo):
return (
ChromecastInfo(
services=self.services,
uuid=self.uuid,
model_name=self.model_name,
friendly_name=self.friendly_name,
cast_type=self.cast_type,
manufacturer=self.manufacturer,
is_dynamic_group=self.is_dynamic_group,
)
== other
)
return super().__eq__(other)
if service is None:
service = pychromecast.discovery.ServiceInfo(
pychromecast.const.SERVICE_TYPE_HOST, (host, port)
)
return ExtendedChromecastInfo(
host=host,
port=port,
services={service},
uuid=uuid,
model_name="Chromecast",
friendly_name="Speaker",
cast_type=CAST_TYPE_GROUP if port != 8009 else CAST_TYPE_CHROMECAST,
manufacturer="Nabu Casa",
return ChromecastInfo(
cast_info=pychromecast.models.CastInfo(
services={service},
uuid=uuid,
model_name="Chromecast",
friendly_name="Speaker",
host=host,
port=port,
cast_type=CAST_TYPE_GROUP if port != 8009 else CAST_TYPE_CHROMECAST,
manufacturer="Nabu Casa",
)
)
@ -154,12 +135,12 @@ async def async_setup_cast_internal_discovery(hass, config=None):
browser.devices[info.uuid] = pychromecast.discovery.CastInfo(
{service},
info.uuid,
info.model_name,
info.cast_info.model_name,
info.friendly_name,
info.host,
info.port,
info.cast_type,
info.manufacturer,
info.cast_info.host,
info.cast_info.port,
info.cast_info.cast_type,
info.cast_info.manufacturer,
)
discovery_callback(info.uuid, "")
@ -168,15 +149,15 @@ async def async_setup_cast_internal_discovery(hass, config=None):
remove_callback(
info.uuid,
service_name,
pychromecast.discovery.CastInfo(
pychromecast.models.CastInfo(
set(),
info.uuid,
info.model_name,
info.friendly_name,
info.host,
info.port,
info.cast_type,
info.manufacturer,
info.cast_info.model_name,
info.cast_info.friendly_name,
info.cast_info.host,
info.cast_info.port,
info.cast_info.cast_type,
info.cast_info.manufacturer,
),
)
@ -187,7 +168,7 @@ async def async_setup_media_player_cast(hass: HomeAssistant, info: ChromecastInf
"""Set up the cast platform with async_setup_component."""
browser = MagicMock(devices={}, zc={})
chromecast = get_fake_chromecast(info)
zconf = get_fake_zconf(host=info.host, port=info.port)
zconf = get_fake_zconf(host=info.cast_info.host, port=info.cast_info.port)
with patch(
"homeassistant.components.cast.discovery.pychromecast.get_chromecast_from_cast_info",
@ -210,12 +191,12 @@ async def async_setup_media_player_cast(hass: HomeAssistant, info: ChromecastInf
browser.devices[info.uuid] = pychromecast.discovery.CastInfo(
{FAKE_MDNS_SERVICE},
info.uuid,
info.model_name,
info.cast_info.model_name,
info.friendly_name,
info.host,
info.port,
info.cast_type,
info.manufacturer,
info.cast_info.host,
info.cast_info.port,
info.cast_info.cast_type,
info.cast_info.manufacturer,
)
discovery_callback(info.uuid, FAKE_MDNS_SERVICE[1])
@ -228,12 +209,12 @@ async def async_setup_media_player_cast(hass: HomeAssistant, info: ChromecastInf
browser.devices[info.uuid] = pychromecast.discovery.CastInfo(
{FAKE_MDNS_SERVICE},
info.uuid,
info.model_name,
info.cast_info.model_name,
info.friendly_name,
info.host,
info.port,
info.cast_type,
info.manufacturer,
info.cast_info.host,
info.cast_info.port,
info.cast_info.cast_type,
info.cast_info.manufacturer,
)
discovery_callback(info.uuid, FAKE_MDNS_SERVICE[1])
@ -268,50 +249,32 @@ async def test_start_discovery_called_once(hass, castbrowser_mock):
assert castbrowser_mock.return_value.start_discovery.call_count == 1
async def test_internal_discovery_callback_fill_out_fail(hass):
"""Test internal discovery automatically filling out information."""
discover_cast, _, _ = await async_setup_cast_internal_discovery(hass)
info = get_fake_chromecast_info(host="host1", service=FAKE_MDNS_SERVICE)
zconf = get_fake_zconf(host="host1", port=8009)
full_info = (
info # attr.evolve(info, model_name="", friendly_name="Speaker", uuid=FakeUUID)
)
with patch(
"homeassistant.components.cast.helpers.dial.get_device_status",
return_value=None,
), patch(
"homeassistant.components.cast.discovery.ChromeCastZeroconf.get_zeroconf",
return_value=zconf,
):
signal = MagicMock()
async_dispatcher_connect(hass, "cast_discovered", signal)
discover_cast(FAKE_MDNS_SERVICE, info)
await hass.async_block_till_done()
# when called with incomplete info, it should use HTTP to get missing
discover = signal.mock_calls[0][1][0]
assert discover == full_info
async def test_internal_discovery_callback_fill_out_group(hass):
async def test_internal_discovery_callback_fill_out_group_fail(
hass, get_multizone_status_mock
):
"""Test internal discovery automatically filling out information."""
discover_cast, _, _ = await async_setup_cast_internal_discovery(hass)
info = get_fake_chromecast_info(host="host1", port=12345, service=FAKE_MDNS_SERVICE)
zconf = get_fake_zconf(host="host1", port=12345)
full_info = attr.evolve(
info,
model_name="Chromecast",
friendly_name="Speaker",
uuid=FakeUUID,
cast_info=pychromecast.discovery.CastInfo(
services=info.cast_info.services,
uuid=FakeUUID,
model_name="Chromecast",
friendly_name="Speaker",
host=info.cast_info.host,
port=info.cast_info.port,
cast_type=info.cast_info.cast_type,
manufacturer=info.cast_info.manufacturer,
),
is_dynamic_group=False,
)
get_multizone_status_mock.assert_not_called()
get_multizone_status_mock.return_value = None
with patch(
"homeassistant.components.cast.helpers.dial.get_device_status",
return_value=full_info,
), patch(
"homeassistant.components.cast.discovery.ChromeCastZeroconf.get_zeroconf",
return_value=zconf,
):
@ -324,6 +287,48 @@ async def test_internal_discovery_callback_fill_out_group(hass):
# when called with incomplete info, it should use HTTP to get missing
discover = signal.mock_calls[0][1][0]
assert discover == full_info
get_multizone_status_mock.assert_called_once()
async def test_internal_discovery_callback_fill_out_group(
hass, get_multizone_status_mock
):
"""Test internal discovery automatically filling out information."""
discover_cast, _, _ = await async_setup_cast_internal_discovery(hass)
info = get_fake_chromecast_info(host="host1", port=12345, service=FAKE_MDNS_SERVICE)
zconf = get_fake_zconf(host="host1", port=12345)
full_info = attr.evolve(
info,
cast_info=pychromecast.discovery.CastInfo(
services=info.cast_info.services,
uuid=FakeUUID,
model_name="Chromecast",
friendly_name="Speaker",
host=info.cast_info.host,
port=info.cast_info.port,
cast_type=info.cast_info.cast_type,
manufacturer=info.cast_info.manufacturer,
),
is_dynamic_group=False,
)
get_multizone_status_mock.assert_not_called()
get_multizone_status_mock.return_value = None
with patch(
"homeassistant.components.cast.discovery.ChromeCastZeroconf.get_zeroconf",
return_value=zconf,
):
signal = MagicMock()
async_dispatcher_connect(hass, "cast_discovered", signal)
discover_cast(FAKE_MDNS_SERVICE, info)
await hass.async_block_till_done()
# when called with incomplete info, it should use HTTP to get missing
discover = signal.mock_calls[0][1][0]
assert discover == full_info
get_multizone_status_mock.assert_called_once()
async def test_stop_discovery_called_on_stop(hass, castbrowser_mock):
@ -437,7 +442,9 @@ async def test_auto_cast_chromecasts(hass):
assert add_dev1.call_count == 2
async def test_discover_dynamic_group(hass, dial_mock, get_chromecast_mock, caplog):
async def test_discover_dynamic_group(
hass, get_multizone_status_mock, get_chromecast_mock, caplog
):
"""Test dynamic group does not create device or entity."""
cast_1 = get_fake_chromecast_info(host="host_1", port=23456, uuid=FakeUUID)
cast_2 = get_fake_chromecast_info(host="host_2", port=34567, uuid=FakeUUID2)
@ -451,7 +458,7 @@ async def test_discover_dynamic_group(hass, dial_mock, get_chromecast_mock, capl
tmp1.uuid = FakeUUID
tmp2 = MagicMock()
tmp2.uuid = FakeUUID2
dial_mock.get_multizone_status.return_value.dynamic_groups = [tmp1, tmp2]
get_multizone_status_mock.return_value.dynamic_groups = [tmp1, tmp2]
get_chromecast_mock.assert_not_called()
discover_cast, remove_cast, add_dev1 = await async_setup_cast_internal_discovery(
@ -492,7 +499,7 @@ async def test_discover_dynamic_group(hass, dial_mock, get_chromecast_mock, capl
get_chromecast_mock.assert_called()
get_chromecast_mock.reset_mock()
assert add_dev1.call_count == 0
assert reg.async_get_entity_id("media_player", "cast", cast_1.uuid) is None
assert reg.async_get_entity_id("media_player", "cast", cast_2.uuid) is None
# Get update for cast service
with patch(
@ -601,9 +608,6 @@ async def test_entity_cast_status(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
chromecast.cast_type = pychromecast.const.CAST_TYPE_CHROMECAST
@ -618,7 +622,7 @@ async def test_entity_cast_status(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
# No media status, pause, play, stop not supported
assert state.attributes.get("supported_features") == (
@ -756,9 +760,6 @@ async def test_entity_play_media(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, _ = get_status_callbacks(chromecast)
@ -772,7 +773,7 @@ async def test_entity_play_media(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
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)
@ -785,9 +786,6 @@ async def test_entity_play_media_cast(hass: HomeAssistant, quick_play_mock):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, _ = get_status_callbacks(chromecast)
@ -801,7 +799,7 @@ async def test_entity_play_media_cast(hass: HomeAssistant, quick_play_mock):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
# Play_media - cast with app ID
await common.async_play_media(hass, "cast", '{"app_id": "abc123"}', entity_id)
@ -830,9 +828,6 @@ async def test_entity_play_media_cast_invalid(hass, caplog, quick_play_mock):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, _ = get_status_callbacks(chromecast)
@ -846,7 +841,7 @@ async def test_entity_play_media_cast_invalid(hass, caplog, quick_play_mock):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
# play_media - media_type cast with invalid JSON
with pytest.raises(json.decoder.JSONDecodeError):
@ -903,9 +898,6 @@ async def test_entity_media_content_type(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, media_status_cb = get_status_callbacks(chromecast)
@ -919,7 +911,7 @@ async def test_entity_media_content_type(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
media_status = MagicMock(images=None)
media_status.media_is_movie = False
@ -957,9 +949,6 @@ async def test_entity_control(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
chromecast.cast_type = pychromecast.const.CAST_TYPE_CHROMECAST
@ -982,7 +971,7 @@ async def test_entity_control(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "playing"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
assert state.attributes.get("supported_features") == (
SUPPORT_PAUSE
@ -1075,9 +1064,6 @@ async def test_entity_media_states(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, media_status_cb = get_status_callbacks(chromecast)
@ -1091,7 +1077,7 @@ async def test_entity_media_states(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
media_status = MagicMock(images=None)
media_status.player_is_playing = True
@ -1134,9 +1120,6 @@ async def test_entity_media_states_lovelace_app(hass: HomeAssistant):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
cast_status_cb, conn_status_cb, media_status_cb = get_status_callbacks(chromecast)
@ -1150,7 +1133,7 @@ async def test_entity_media_states_lovelace_app(hass: HomeAssistant):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
chromecast.app_id = CAST_APP_ID_HOMEASSISTANT_LOVELACE
cast_status = MagicMock()
@ -1204,9 +1187,6 @@ async def test_group_media_states(hass, mz_mock):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
_, conn_status_cb, media_status_cb, group_media_status_cb = get_status_callbacks(
@ -1222,7 +1202,7 @@ async def test_group_media_states(hass, mz_mock):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
group_media_status = MagicMock(images=None)
player_media_status = MagicMock(images=None)
@ -1257,9 +1237,6 @@ async def test_group_media_control(hass, mz_mock):
reg = er.async_get(hass)
info = get_fake_chromecast_info()
full_info = attr.evolve(
info, model_name="google home", friendly_name="Speaker", uuid=FakeUUID
)
chromecast, _ = await async_setup_media_player_cast(hass, info)
@ -1276,7 +1253,7 @@ async def test_group_media_control(hass, mz_mock):
assert state is not None
assert state.name == "Speaker"
assert state.state == "off"
assert entity_id == reg.async_get_entity_id("media_player", "cast", full_info.uuid)
assert entity_id == reg.async_get_entity_id("media_player", "cast", str(info.uuid))
group_media_status = MagicMock(images=None)
player_media_status = MagicMock(images=None)