1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-12-06 18:44:14 -05:00

Make device own required steps when setting playlist

This commit is contained in:
Nathan Spencer
2025-11-26 20:32:12 +00:00
parent 50773c582c
commit 4336f658c4
2 changed files with 10 additions and 5 deletions

View File

@@ -340,7 +340,6 @@ class OasisDeviceMediaPlayerEntity(OasisDeviceEntity, MediaPlayerEntity):
return
if enqueue == MediaPlayerEnqueue.REPLACE:
await device.async_stop()
await device.async_set_playlist(track_ids)
await device.async_play()
return

View File

@@ -11,6 +11,7 @@ from .const import (
LED_EFFECTS,
STATUS_CODE_MAP,
STATUS_ERROR,
STATUS_PLAYING,
STATUS_SLEEPING,
TRACKS,
)
@@ -655,11 +656,16 @@ class OasisDevice:
playlist (int | Iterable[int]): A single track ID or an iterable of track IDs to set as the new playlist.
"""
if isinstance(playlist, int):
playlist_list = [playlist]
else:
playlist_list = list(playlist)
playlist = [playlist]
client = self._require_client()
await client.async_send_set_playlist_command(self, playlist_list)
was_playing = self.status_code == STATUS_PLAYING
# We need to stop the device so we can set the full playlist
await client.async_send_stop_command(self)
await client.async_send_set_playlist_command(self, playlist)
if was_playing and len(playlist) > 0:
await client.async_send_play_command(self)
async def async_set_repeat_playlist(self, repeat: bool) -> None:
"""