1
0
mirror of https://github.com/natekspencer/hacs-oasis_mini.git synced 2025-11-14 16:13:51 -05:00

3 Commits

Author SHA1 Message Date
Nathan Spencer
82a6a3cc1d Add temp fix for firmware 2.02 led issue 2025-03-13 04:32:44 +00:00
Nathan Spencer
e2f5727669 Merge pull request #59 from natekspencer/update-tracks
Update tracks
2025-03-12 22:31:45 -06:00
natekspencer
8650fd597a Update tracks 2025-03-12 19:16:35 +00:00
3 changed files with 70 additions and 18 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, decrypt_svg_content
from .utils import _bit_to_bool, _parse_int, decrypt_svg_content
_LOGGER = logging.getLogger(__name__)
@@ -54,8 +54,8 @@ LED_EFFECTS: Final[dict[str, str]] = {
CLOUD_BASE_URL = "https://app.grounded.so"
BALL_SPEED_MAX: Final = 1000
BALL_SPEED_MIN: Final = 200
BALL_SPEED_MAX: Final = 400
BALL_SPEED_MIN: Final = 100
LED_SPEED_MAX: Final = 90
LED_SPEED_MIN: Final = -90
@@ -209,25 +209,29 @@ class OasisMini:
raw_status = await self._async_get(params={"GETSTATUS": ""})
_LOGGER.debug("Status: %s", raw_status)
values = raw_status.split(";")
playlist = [int(track) for track in values[3].split(",") if track]
playlist = [_parse_int(track) for track in values[3].split(",") if track]
shift = len(values) - 18 if len(values) > 17 else 0
status = {
"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
"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
"playlist": playlist,
"playlist_index": min(int(values[4]), len(playlist)), # index of above
"progress": int(values[5]), # 0 - max svg path
"playlist_index": min(_parse_int(values[4]), len(playlist)), # noqa: E501; index of above
"progress": _parse_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": 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(values[16]),
"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(values[16 + shift]),
"autoclean": _bit_to_bool(values[17 + shift])
if len(values) > 17
else False,
}
for key, value in status.items():
if (old_value := getattr(self, key, None)) != value:

View File

@@ -3531,6 +3531,16 @@
"1": 4116
}
},
"5564": {
"id": 5564,
"name": "SnowFlake (C C)",
"author": "RiverRatDC",
"image": "2024/12/3f5e5f460465ab17ea0003826ac3ded5.svg",
"clean_pattern": null,
"reduced_svg_content": {
"1": 26547
}
},
"4803": {
"id": 4803,
"name": "Snowman Frosty",
@@ -4538,6 +4548,16 @@
},
"updated_at": "2024-08-04T15:58:49.000000Z"
},
"2207": {
"id": 2207,
"name": "UConn",
"author": "JeffDLowe",
"image": "2024/08/841e0c9b75cbe33f152672f76d8909b6.svg",
"clean_pattern": null,
"reduced_svg_content": {
"1": 23086
}
},
"218": {
"id": 218,
"name": "Unicorn",
@@ -4702,6 +4722,16 @@
"1": 2310
}
},
"2146": {
"id": 2146,
"name": "Warped Waves",
"author": "Crystal James",
"image": "2024/08/794b3a39e45f75fd487728e5cf9fb1ed.svg",
"clean_pattern": null,
"reduced_svg_content": {
"1": 17243
}
},
"555": {
"id": 555,
"name": "Wavy dude",
@@ -4816,6 +4846,16 @@
"1": 42218
}
},
"7221": {
"id": 7221,
"name": "Winter Sand",
"author": "000843.bf34f133184943939b950674aaaa4ac9.2327",
"image": "2025/02/48f5d7a080145e4f8442eb0b1b5f3872.svg",
"clean_pattern": null,
"reduced_svg_content": {
"1": 17842
}
},
"500": {
"id": 500,
"name": "Wipe Left to Right",

View File

@@ -26,6 +26,14 @@ 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")):