From 965674061fdf456abf9ced88bb72c6eb8a095872 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 06:43:37 +0000 Subject: [PATCH 1/3] Initial plan From 67e3b4a7755df7d9e069b1771ae3d5d7a8636984 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 06:46:52 +0000 Subject: [PATCH 2/3] Remove misleading multiplatform test that bypasses real implementation Co-authored-by: dan-s-github <20974454+dan-s-github@users.noreply.github.com> --- tests/components/media_player/test_init.py | 55 ---------------------- 1 file changed, 55 deletions(-) diff --git a/tests/components/media_player/test_init.py b/tests/components/media_player/test_init.py index f81f12e184b572..11e815083f495c 100644 --- a/tests/components/media_player/test_init.py +++ b/tests/components/media_player/test_init.py @@ -720,58 +720,3 @@ async def test_get_groupable_players_same_platform_only(hass: HomeAssistant) -> assert entity_id == "media_player.kitchen", ( f"Unexpected entity {entity_id} in groupable players" ) - - -async def test_get_groupable_players_multiplatform(hass: HomeAssistant) -> None: - """Test that get_groupable_players service can return players from different platforms. - - This tests cross-platform grouping capability when the service is implemented - to support grouping entities from different platforms. - """ - # Set up demo media player platform - await async_setup_component( - hass, "media_player", {"media_player": {"platform": "demo"}} - ) - await hass.async_block_till_done() - - # Create entity IDs for different platforms - spotify_id = "media_player.spotify" - sonos_id = "media_player.sonos_living_room" - airplay_id = "media_player.airplay_speaker" - - # Mock the async_get_groupable_players method to return cross-platform results - multiplatform_result = { - "result": [ - spotify_id, - sonos_id, - airplay_id, - ] - } - - with patch( - "homeassistant.components.media_player.MediaPlayerEntity.async_get_groupable_players", - return_value=multiplatform_result, - ): - # Call the service (not the method directly) - result = await hass.services.async_call( - "media_player", - SERVICE_GET_GROUPABLE_MEMBERS, - { - ATTR_ENTITY_ID: "media_player.walkman" - }, # Music player with grouping support - blocking=True, - return_response=True, - ) - - # Verify service returns proper response structure - assert "media_player.walkman" in result - assert isinstance(result["media_player.walkman"], dict) - assert "result" in result["media_player.walkman"] - - # Verify multiplatform results are returned - groupable_players = result["media_player.walkman"]["result"] - assert isinstance(groupable_players, list) - assert len(groupable_players) == 3 - assert spotify_id in groupable_players - assert sonos_id in groupable_players - assert airplay_id in groupable_players From 4b8f5b8b68b35b87639d3e5486b88d7a2b6cae54 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 21 Jan 2026 06:55:58 +0000 Subject: [PATCH 3/3] Add test for multi-platform grouping via method override Co-authored-by: dan-s-github <20974454+dan-s-github@users.noreply.github.com> --- tests/components/media_player/test_init.py | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/components/media_player/test_init.py b/tests/components/media_player/test_init.py index 11e815083f495c..08754be4582176 100644 --- a/tests/components/media_player/test_init.py +++ b/tests/components/media_player/test_init.py @@ -1,6 +1,7 @@ """Test the base functions of the media player.""" from http import HTTPStatus +from typing import Any from unittest.mock import patch import pytest @@ -720,3 +721,63 @@ async def test_get_groupable_players_same_platform_only(hass: HomeAssistant) -> assert entity_id == "media_player.kitchen", ( f"Unexpected entity {entity_id} in groupable players" ) + + +async def test_get_groupable_players_multiplatform_override( + hass: HomeAssistant, +) -> None: + """Test that integrations can override async_get_groupable_players for multi-platform support. + + This demonstrates how an integration can override the default implementation + to return entities from multiple platforms that it can group together. + """ + + class MultiPlatformMediaPlayer(MediaPlayerEntity): + """Test media player that supports grouping across platforms.""" + + _attr_supported_features = media_player.MediaPlayerEntityFeature.GROUPING + + def __init__(self, entity_id: str, name: str) -> None: + """Initialize the test entity.""" + self.entity_id = entity_id + self._attr_name = name + + async def async_get_groupable_players(self) -> dict[str, Any]: + """Override to return multi-platform groupable players.""" + # Integration-specific logic that can determine which players + # from different platforms can be grouped together + return { + "result": [ + "media_player.spotify_player", + "media_player.sonos_living_room", + "media_player.chromecast_kitchen", + ] + } + + # Create and register the custom entity + entity = MultiPlatformMediaPlayer("media_player.test_player", "Test Player") + entity.hass = hass + entity.platform = MockEntityPlatform(hass) + + # Add entity to registry and component + component = await media_player.async_get_component(hass) + component.entities.append(entity) + await entity.async_internal_added_to_hass() + + # Call the service + result = await hass.services.async_call( + "media_player", + SERVICE_GET_GROUPABLE_MEMBERS, + {ATTR_ENTITY_ID: "media_player.test_player"}, + blocking=True, + return_response=True, + ) + + # Verify the overridden implementation's results are returned + assert "media_player.test_player" in result + groupable_players = result["media_player.test_player"]["result"] + assert isinstance(groupable_players, list) + assert len(groupable_players) == 3 + assert "media_player.spotify_player" in groupable_players + assert "media_player.sonos_living_room" in groupable_players + assert "media_player.chromecast_kitchen" in groupable_players