mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +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:
|
if self.is_grouped and not self.is_master:
|
||||||
return MediaPlayerState.IDLE
|
return MediaPlayerState.IDLE
|
||||||
|
|
||||||
status = self._status.state
|
match self._status.state:
|
||||||
if status in ("pause", "stop"):
|
case "pause":
|
||||||
return MediaPlayerState.PAUSED
|
return MediaPlayerState.PAUSED
|
||||||
if status in ("stream", "play"):
|
case "stream" | "play":
|
||||||
return MediaPlayerState.PLAYING
|
return MediaPlayerState.PLAYING
|
||||||
return MediaPlayerState.IDLE
|
case _:
|
||||||
|
return MediaPlayerState.IDLE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self) -> str | None:
|
def media_title(self) -> str | None:
|
||||||
|
@ -130,6 +130,26 @@ async def test_attributes_set(
|
|||||||
assert state == snapshot(exclude=props("media_position_updated_at"))
|
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(
|
async def test_status_updated(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
setup_config_entry: None,
|
setup_config_entry: None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user