mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Map "stop" to MediaPlayerState.IDLE in bluesound integration (#129904)
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
parent
a7ba4bd086
commit
2c1db10986
@ -364,12 +364,13 @@ class BluesoundPlayer(MediaPlayerEntity):
|
||||
if self.is_grouped and not self.is_master:
|
||||
return MediaPlayerState.IDLE
|
||||
|
||||
status = self._status.state
|
||||
if status in ("pause", "stop"):
|
||||
return MediaPlayerState.PAUSED
|
||||
if status in ("stream", "play"):
|
||||
return MediaPlayerState.PLAYING
|
||||
return MediaPlayerState.IDLE
|
||||
match self._status.state:
|
||||
case "pause":
|
||||
return MediaPlayerState.PAUSED
|
||||
case "stream" | "play":
|
||||
return MediaPlayerState.PLAYING
|
||||
case _:
|
||||
return MediaPlayerState.IDLE
|
||||
|
||||
@property
|
||||
def media_title(self) -> str | None:
|
||||
|
@ -130,6 +130,26 @@ async def test_attributes_set(
|
||||
assert state == snapshot(exclude=props("media_position_updated_at"))
|
||||
|
||||
|
||||
async def test_stop_maps_to_idle(
|
||||
hass: HomeAssistant,
|
||||
setup_config_entry: None,
|
||||
player_mocks: PlayerMocks,
|
||||
) -> None:
|
||||
"""Test the media player stop maps to idle."""
|
||||
player_mocks.player_data.status_long_polling_mock.set(
|
||||
dataclasses.replace(
|
||||
player_mocks.player_data.status_long_polling_mock.get(), state="stop"
|
||||
)
|
||||
)
|
||||
|
||||
# give the long polling loop a chance to update the state; this could be any async call
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert (
|
||||
hass.states.get("media_player.player_name1111").state == MediaPlayerState.IDLE
|
||||
)
|
||||
|
||||
|
||||
async def test_status_updated(
|
||||
hass: HomeAssistant,
|
||||
setup_config_entry: None,
|
||||
|
Loading…
x
Reference in New Issue
Block a user