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 return
if enqueue == MediaPlayerEnqueue.REPLACE: if enqueue == MediaPlayerEnqueue.REPLACE:
await device.async_stop()
await device.async_set_playlist(track_ids) await device.async_set_playlist(track_ids)
await device.async_play() await device.async_play()
return return

View File

@@ -11,6 +11,7 @@ from .const import (
LED_EFFECTS, LED_EFFECTS,
STATUS_CODE_MAP, STATUS_CODE_MAP,
STATUS_ERROR, STATUS_ERROR,
STATUS_PLAYING,
STATUS_SLEEPING, STATUS_SLEEPING,
TRACKS, 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. playlist (int | Iterable[int]): A single track ID or an iterable of track IDs to set as the new playlist.
""" """
if isinstance(playlist, int): if isinstance(playlist, int):
playlist_list = [playlist] playlist = [playlist]
else:
playlist_list = list(playlist)
client = self._require_client() 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: async def async_set_repeat_playlist(self, repeat: bool) -> None:
""" """