Support media player grouping in bluesound integration#159455
Conversation
|
Hey there @thrawnarn, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Pull request overview
This PR adds support for standard Home Assistant media_player.join and media_player.unjoin services to the Bluesound integration, while deprecating the custom bluesound.join and bluesound.unjoin actions. The PR introduces a group_members attribute to track media player grouping relationships and updates the supported features to include MediaPlayerEntityFeature.GROUPING.
Key changes:
- Implements
async_join_players()andasync_unjoin_player()methods for standard media player grouping - Adds
group_membersproperty andrebuild_group_members()method to track grouped entities - Adds deprecation warnings to the legacy
bluesound.joinandbluesound.unjoinservices with a breaking change scheduled for version 2026.12.0
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/bluesound/media_player.py |
Implements new media player grouping feature with async_join_players() and async_unjoin_player() methods; adds group_members tracking; deprecates legacy join/unjoin services |
homeassistant/components/bluesound/utils.py |
Adds id_to_paired_player() utility function to convert id strings to PairedPlayer objects |
homeassistant/components/bluesound/strings.json |
Adds deprecation warning messages for bluesound.join and bluesound.unjoin actions |
tests/components/bluesound/test_media_player.py |
Adds comprehensive tests for new grouping functionality including test_join_players(), test_unjoin_player(), and test_attr_group_members() |
tests/components/bluesound/snapshots/test_media_player.ambr |
Updates snapshot to reflect new group_members attribute and updated supported_features with GROUPING flag |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (1)
tests/components/bluesound/test_media_player.py:337
- Missing test coverage for deprecation warnings. The new code adds deprecation warnings for
bluesound.joinandbluesound.unjoinservices (lines 473-485 and 497-509 in media_player.py). Tests should verify that calling these deprecated services creates the appropriate repair issues viair.async_create_issue. This ensures the deprecation mechanism works correctly and users receive proper warnings.
async def test_join(
hass: HomeAssistant,
setup_config_entry: None,
setup_config_entry_secondary: None,
player_mocks: PlayerMocks,
) -> None:
"""Test the bluesound.join action."""
await hass.services.async_call(
DOMAIN,
SERVICE_JOIN,
{
ATTR_ENTITY_ID: "media_player.player_name1111",
ATTR_MASTER: "media_player.player_name2222",
},
blocking=True,
)
player_mocks.player_data_secondary.player.add_follower.assert_called_once_with(
"1.1.1.1", 11000
)
async def test_unjoin(
hass: HomeAssistant,
setup_config_entry: None,
setup_config_entry_secondary: None,
player_mocks: PlayerMocks,
) -> None:
"""Test the bluesound.unjoin action."""
updated_sync_status = dataclasses.replace(
player_mocks.player_data.sync_status_long_polling_mock.get(),
leader=PairedPlayer("2.2.2.2", 11000),
)
player_mocks.player_data.sync_status_long_polling_mock.set(updated_sync_status)
# give the long polling loop a chance to update the state; this could be any async call
await hass.async_block_till_done()
await hass.services.async_call(
DOMAIN,
"unjoin",
{ATTR_ENTITY_ID: "media_player.player_name1111"},
blocking=True,
)
player_mocks.player_data_secondary.player.remove_follower.assert_called_once_with(
"1.1.1.1", 11000
)
Proposed change
This adds support for
media_player.joinandmedia_player.unjoin. This also deprecates the custom actions for grouping:bluesound.joinandbluesound.unjoin.Type of change
Additional information
bluesound.joinandbluesound.unjoinhome-assistant.io#42651Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: