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

Address PR review

This commit is contained in:
Nathan Spencer
2025-11-25 19:08:02 +00:00
parent c1754ad959
commit e1599b7c47
5 changed files with 28 additions and 28 deletions

View File

@@ -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 or '0'}"
payload = f"WRIJOBLIST={track_str}"
await self._publish_command(device, payload)
async def async_send_set_repeat_playlist_command(

View File

@@ -14,7 +14,13 @@ from .const import (
STATUS_SLEEPING,
TRACKS,
)
from .utils import _bit_to_bool, _parse_int, create_svg, decrypt_svg_content
from .utils import (
_bit_to_bool,
_parse_int,
create_svg,
decrypt_svg_content,
get_url_for_image,
)
if TYPE_CHECKING: # avoid runtime circular imports
from .clients import OasisCloudClient
@@ -399,10 +405,10 @@ class OasisDevice:
Get the full HTTPS URL for the current track's image if available.
Returns:
str: Full URL to the track image (https://app.grounded.so/uploads/<image>), or `None` if no image is available.
str: Full URL to the track image or `None` if no image is available.
"""
if (track := self.track) and (image := track.get("image")):
return f"https://app.grounded.so/uploads/{image}"
if track := self.track:
return get_url_for_image(track.get("image"))
return None
@property

View File

@@ -202,7 +202,12 @@ def decrypt_svg_content(svg_content: dict[str, str]):
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 [])]
return [track["id"] for track in (playlist.get("patterns") or []) if "id" in track]
def get_url_for_image(image: str | None) -> str | None:
"""Get the full URL for an image."""
return f"https://app.grounded.so/uploads/{image}" if image else None
def now() -> datetime: