1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-18 01:53:41 -05:00

10 Commits

Author SHA1 Message Date
Nathan Spencer
b5b3e691e2 Merge pull request #73 from natekspencer/update-tracks
Update tracks
2025-06-30 09:37:32 -06:00
natekspencer
52b741fb71 Update tracks 2025-06-26 19:18:53 +00:00
Nathan Spencer
dc9f21b332 Merge pull request #70 from natekspencer/update-tracks
Update tracks
2025-06-10 14:01:11 -06:00
natekspencer
002898de97 Update tracks 2025-06-03 19:18:35 +00:00
Nathan Spencer
1296b309d4 Merge pull request #69 from natekspencer/update-tracks
Update tracks
2025-04-29 13:53:54 -06:00
natekspencer
9cb8b6d398 Update tracks 2025-04-29 19:18:38 +00:00
Nathan Spencer
a6022df49d Merge pull request #68 from natekspencer/update-tracks
Update tracks
2025-04-15 15:07:07 -06:00
natekspencer
839ba6ff35 Update tracks 2025-04-15 19:18:32 +00:00
Nathan Spencer
39b333be8e Merge pull request #67 from natekspencer/update-tracks
Update tracks
2025-03-26 13:19:18 -06:00
natekspencer
2afb8acf0e Update tracks 2025-03-26 19:17:57 +00:00
3 changed files with 2363 additions and 57 deletions

View File

@@ -10,7 +10,7 @@ from urllib.parse import urljoin
from aiohttp import ClientResponseError, ClientSession
from .const import TRACKS
from .utils import _bit_to_bool, _parse_int, decrypt_svg_content
from .utils import _bit_to_bool, decrypt_svg_content
_LOGGER = logging.getLogger(__name__)
@@ -55,8 +55,8 @@ LED_EFFECTS: Final[dict[str, str]] = {
CLOUD_BASE_URL = "https://app.grounded.so"
BALL_SPEED_MAX: Final = 400
BALL_SPEED_MIN: Final = 100
BALL_SPEED_MAX: Final = 1000
BALL_SPEED_MIN: Final = 200
LED_SPEED_MAX: Final = 90
LED_SPEED_MIN: Final = -90
@@ -210,29 +210,25 @@ class OasisMini:
raw_status = await self._async_get(params={"GETSTATUS": ""})
_LOGGER.debug("Status: %s", raw_status)
values = raw_status.split(";")
playlist = [_parse_int(track) for track in values[3].split(",") if track]
shift = len(values) - 18 if len(values) > 17 else 0
playlist = [int(track) for track in values[3].split(",") if track]
status = {
"status_code": _parse_int(values[0]), # see status code map
"error": _parse_int(values[1]), # noqa: E501; error, 0 = none, and 10 = ?, 18 = can't download?
"ball_speed": _parse_int(values[2]), # 200 - 1000
"status_code": int(values[0]), # see status code map
"error": int(values[1]), # noqa: E501; error, 0 = none, and 10 = ?, 18 = can't download?
"ball_speed": int(values[2]), # 200 - 1000
"playlist": playlist,
"playlist_index": min(_parse_int(values[4]), len(playlist)), # noqa: E501; index of above
"progress": _parse_int(values[5]), # 0 - max svg path
"playlist_index": min(int(values[4]), len(playlist)), # index of above
"progress": int(values[5]), # 0 - max svg path
"led_effect": values[6], # led effect (code lookup)
"led_color_id": values[7], # led color id?
"led_speed": _parse_int(values[8]), # -90 - 90
"brightness": _parse_int(values[9]), # noqa: E501; 0 - 200 in app, but seems to be 0 (off) to 304 (max), then repeats
"color": values[10] if "#" in values[10] else None, # hex color code
"busy": _bit_to_bool(values[11 + shift]), # noqa: E501; device is busy (downloading track, centering, software update)?
"download_progress": _parse_int(values[12 + shift]),
"max_brightness": _parse_int(values[13 + shift]),
"wifi_connected": _bit_to_bool(values[14 + shift]),
"repeat_playlist": _bit_to_bool(values[15 + shift]),
"autoplay": AUTOPLAY_MAP.get(value := values[16 + shift], value),
"autoclean": _bit_to_bool(values[17 + shift])
if len(values) > 17
else False,
"led_speed": int(values[8]), # -90 - 90
"brightness": int(values[9]) if values[10] else 0, # noqa: E501; 0 - 200 in app, but seems to be 0 (off) to 304 (max), then repeats
"color": values[10] or None, # hex color code
"busy": _bit_to_bool(values[11]), # noqa: E501; device is busy (downloading track, centering, software update)?
"download_progress": int(values[12]),
"max_brightness": int(values[13]),
"wifi_connected": _bit_to_bool(values[14]),
"repeat_playlist": _bit_to_bool(values[15]),
"autoplay": AUTOPLAY_MAP.get(value := values[16], value),
}
for key, value in status.items():
if (old_value := getattr(self, key, None)) != value:

File diff suppressed because it is too large Load Diff

View File

@@ -26,14 +26,6 @@ def _bit_to_bool(val: str) -> bool:
return val == "1"
def _parse_int(val: str) -> int:
"""Convert an int string to int."""
try:
return int(val)
except Exception:
return 0
def draw_svg(track: dict, progress: int, model_id: str) -> str | None:
"""Draw SVG."""
if track and (svg_content := track.get("svg_content")):