mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-11-17 01:23:43 -05:00
Add additional features
This commit is contained in:
@@ -12,3 +12,18 @@ from .pyoasismini import OasisMini
|
||||
def create_client(data: dict[str, Any]) -> OasisMini:
|
||||
"""Create a Oasis Mini local client."""
|
||||
return OasisMini(data[CONF_HOST], data.get(CONF_ACCESS_TOKEN))
|
||||
|
||||
|
||||
async def add_and_play_track(device: OasisMini, track: int) -> None:
|
||||
"""Add and play a track."""
|
||||
if track not in device.playlist:
|
||||
await device.async_add_track_to_playlist(track)
|
||||
|
||||
# Move track to next item in the playlist and then select it
|
||||
if (index := device.playlist.index(track)) != device.playlist_index:
|
||||
if index != (_next := min(device.playlist_index + 1, len(device.playlist))):
|
||||
await device.async_move_track(index, _next)
|
||||
await device.async_change_track(_next)
|
||||
|
||||
if device.status_code != 4:
|
||||
await device.async_play()
|
||||
|
||||
Reference in New Issue
Block a user