mirror of
https://github.com/natekspencer/hacs-oasis_mini.git
synced 2025-12-06 18:44:14 -05:00
Enhance media_player with browse/search capability
This commit is contained in:
@@ -495,7 +495,7 @@ class OasisMqttClient(OasisClientProtocol):
|
||||
playlist (list[int]): Ordered list of track indices to apply as the device's playlist.
|
||||
"""
|
||||
track_str = ",".join(map(str, playlist))
|
||||
payload = f"WRIJOBLIST={track_str}"
|
||||
payload = f"WRIJOBLIST={track_str or '0'}"
|
||||
await self._publish_command(device, payload)
|
||||
|
||||
async def async_send_set_repeat_playlist_command(
|
||||
@@ -796,7 +796,11 @@ class OasisMqttClient(OasisClientProtocol):
|
||||
elif status_name == "OASIS_SPEEED":
|
||||
data["ball_speed"] = int(payload)
|
||||
elif status_name == "JOBLIST":
|
||||
data["playlist"] = [int(x) for x in payload.split(",") if x]
|
||||
data["playlist"] = [
|
||||
track_id
|
||||
for track_str in payload.split(",")
|
||||
if (track_id := _parse_int(track_str))
|
||||
]
|
||||
elif status_name == "CURRENTJOB":
|
||||
data["playlist_index"] = int(payload)
|
||||
elif status_name == "CURRENTLINE":
|
||||
|
||||
@@ -282,7 +282,11 @@ class OasisDevice:
|
||||
)
|
||||
return None
|
||||
|
||||
playlist = [_parse_int(track) for track in values[3].split(",") if track]
|
||||
playlist = [
|
||||
track_id
|
||||
for track_str in values[3].split(",")
|
||||
if (track_id := _parse_int(track_str))
|
||||
]
|
||||
|
||||
try:
|
||||
status: dict[str, Any] = {
|
||||
@@ -616,6 +620,10 @@ class OasisDevice:
|
||||
client = self._require_client()
|
||||
await client.async_send_change_track_command(self, index)
|
||||
|
||||
async def async_clear_playlist(self) -> None:
|
||||
"""Clear the playlist."""
|
||||
await self.async_set_playlist([])
|
||||
|
||||
async def async_add_track_to_playlist(self, track: int | Iterable[int]) -> None:
|
||||
"""
|
||||
Add one or more tracks to the device's playlist via the attached client.
|
||||
|
||||
@@ -200,5 +200,10 @@ def decrypt_svg_content(svg_content: dict[str, str]):
|
||||
return decrypted
|
||||
|
||||
|
||||
def get_track_ids_from_playlist(playlist: dict[str, Any]) -> list[int]:
|
||||
"""Get a list of track ids from a playlist."""
|
||||
return [track["id"] for track in (playlist.get("patterns") or [])]
|
||||
|
||||
|
||||
def now() -> datetime:
|
||||
return datetime.now(UTC)
|
||||
|
||||
Reference in New Issue
Block a user