mirror of
https://github.com/home-assistant/core.git
synced 2026-09-24 07:25:52 -05:00
Skip Bluesound players whose config entry is not loaded (#180559)
This commit is contained in:
@@ -538,8 +538,9 @@ class BluesoundPlayer(CoordinatorEntity[BluesoundCoordinator], MediaPlayerEntity
|
||||
if self.sync_status.leader is None and self.sync_status.followers is None:
|
||||
return []
|
||||
|
||||
# An entry that is not loaded has no runtime data to read a status from
|
||||
config_entries: list[BluesoundConfigEntry] = (
|
||||
self.hass.config_entries.async_entries(DOMAIN)
|
||||
self.hass.config_entries.async_loaded_entries(DOMAIN)
|
||||
)
|
||||
sync_status_list = [
|
||||
x.runtime_data.coordinator.data.sync_status for x in config_entries
|
||||
@@ -609,8 +610,9 @@ class BluesoundPlayer(CoordinatorEntity[BluesoundCoordinator], MediaPlayerEntity
|
||||
|
||||
entity_registry = er.async_get(self.hass)
|
||||
|
||||
# An entry that is not loaded has no runtime data to read a status from
|
||||
config_entries: list[BluesoundConfigEntry] = (
|
||||
self.hass.config_entries.async_entries(DOMAIN)
|
||||
self.hass.config_entries.async_loaded_entries(DOMAIN)
|
||||
)
|
||||
for config_entry in config_entries:
|
||||
entity_entries = er.async_entries_for_config_entry(
|
||||
|
||||
@@ -28,12 +28,15 @@ from homeassistant.components.media_player import (
|
||||
SERVICE_VOLUME_UP,
|
||||
MediaPlayerState,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ServiceValidationError
|
||||
|
||||
from .conftest import PlayerMocks
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("service", "method"),
|
||||
@@ -362,6 +365,34 @@ async def test_attr_bluesound_group(
|
||||
assert attr_bluesound_group == ["player-name1111", "player-name2222"]
|
||||
|
||||
|
||||
async def test_attr_bluesound_group_skips_an_entry_that_is_not_loaded(
|
||||
hass: HomeAssistant,
|
||||
setup_config_entry: None,
|
||||
config_entry_secondary: MockConfigEntry,
|
||||
player_mocks: PlayerMocks,
|
||||
caplog: pytest.LogCaptureFixture,
|
||||
) -> None:
|
||||
"""Test grouping passes over a player whose entry never loaded.
|
||||
|
||||
Such an entry carries no runtime data to read a sync status from.
|
||||
"""
|
||||
config_entry_secondary.add_to_hass(hass)
|
||||
assert config_entry_secondary.state is ConfigEntryState.NOT_LOADED
|
||||
|
||||
updated_sync_status = dataclasses.replace(
|
||||
player_mocks.player_data.sync_status_long_polling_mock.get(),
|
||||
followers=[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()
|
||||
|
||||
assert "runtime_data" not in caplog.text
|
||||
assert hass.states.get("media_player.player_name1111") is not None
|
||||
|
||||
|
||||
async def test_attr_bluesound_group_for_follower(
|
||||
hass: HomeAssistant,
|
||||
setup_config_entry: None,
|
||||
|
||||
Reference in New Issue
Block a user