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

25 Commits

Author SHA1 Message Date
Nathan Spencer
50f7b270f2 Add temp fix for firmware 2.02 led issue 2025-03-26 17:40:26 +00:00
Nathan Spencer
802ce0f9a8 Merge pull request #66 from natekspencer/autoplay-options
Add 24 hours autoplay option
2025-03-26 11:37:08 -06:00
Nathan Spencer
2f25218df5 Merge pull request #64 from natekspencer/update-tracks
Update tracks
2025-03-26 11:34:15 -06:00
Nathan Spencer
de36b6ea67 Add 24 hours autoplay option 2025-03-26 17:33:22 +00:00
natekspencer
4e370d441c Update tracks 2025-03-25 19:17:16 +00:00
Nathan Spencer
cf8e744fa4 Merge pull request #63 from natekspencer/update-tracks
Update tracks
2025-03-18 13:22:09 -06:00
natekspencer
f04438cac8 Update tracks 2025-03-18 19:16:56 +00:00
Nathan Spencer
8fbf7664b1 Merge pull request #62 from natekspencer/update-tracks
Update tracks
2025-03-18 12:24:16 -06:00
natekspencer
5d7176ebaa Update tracks 2025-03-17 19:16:39 +00:00
Nathan Spencer
005a621816 Merge pull request #61 from natekspencer/update-tracks
Update tracks
2025-03-13 13:18:04 -06:00
natekspencer
2feba20b76 Update tracks 2025-03-13 19:16:39 +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
Nathan Spencer
7bef2cbe3b Merge pull request #58 from natekspencer/update-tracks
Update tracks
2025-03-11 15:17:35 -06:00
natekspencer
5ea472821b Update tracks 2025-03-11 19:17:53 +00:00
Nathan Spencer
ab09bde752 Merge pull request #57 from natekspencer/update-tracks
Update tracks
2025-03-09 13:13:57 -06:00
natekspencer
f49b8ce1d2 Update tracks 2025-03-09 19:12:34 +00:00
Nathan Spencer
cbbe8bc10d Merge pull request #56 from natekspencer/pre-commit
Add pre-commit
2025-03-09 11:11:21 -06:00
Nathan Spencer
c2c62bb875 Add pre-commit 2025-03-09 17:07:06 +00:00
Nathan Spencer
108b1850b7 Merge pull request #55 from natekspencer/devcontainer
Update devcontainer
2025-02-03 11:46:16 -07:00
Nathan Spencer
ffc74a9dcb Update devcontainer 2025-02-03 18:44:58 +00:00
Nathan Spencer
f67aee166a Merge pull request #54 from natekspencer/update-tracks
Update tracks
2025-02-02 12:15:58 -07:00
natekspencer
4ed6b1701d Update tracks 2025-02-02 19:15:01 +00:00
Nathan Spencer
ade3e7c666 Merge pull request #53 from natekspencer/update-tracks
Update tracks
2025-01-30 12:16:24 -07:00
natekspencer
4c112f2b06 Update tracks 2025-01-30 19:14:50 +00:00
7 changed files with 1376 additions and 35 deletions

View File

@@ -1,8 +1,8 @@
// See https://aka.ms/vscode-remote/devcontainer.json for format details.
{
"name": "Home Assistant integration development",
"image": "mcr.microsoft.com/devcontainers/python:1-3.13-bullseye",
"postCreateCommand": "sudo apt-get update && sudo apt-get install libturbojpeg0 libpcap0.8 -y",
"image": "mcr.microsoft.com/devcontainers/python:1-3.13-bookworm",
"postCreateCommand": "scripts/setup",
"postAttachCommand": "scripts/setup",
"forwardPorts": [8123],
"customizations": {
@@ -26,7 +26,10 @@
"editor.codeActionsOnSave": {
"source.organizeImports": "always"
},
"files.trimTrailingWhitespace": true
"files.trimTrailingWhitespace": true,
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
}
},

10
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.10
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format

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__)
@@ -32,6 +32,7 @@ AUTOPLAY_MAP = {
"2": "5 minutes",
"3": "10 minutes",
"4": "30 minutes",
"5": "24 hours",
}
LED_EFFECTS: Final[dict[str, str]] = {
@@ -54,8 +55,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 +210,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(value := values[16 + shift], value),
"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:

File diff suppressed because it is too large Load Diff

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")):

View File

@@ -10,4 +10,5 @@ cryptography # should already be installed with Home Assistant
# Development
colorlog
pip>=21.0
pre-commit
ruff

View File

@@ -1,9 +1,13 @@
#!/usr/bin/env bash
sudo apt-get update && sudo apt-get install libturbojpeg0 libpcap0.8 -y
set -e
cd "$(dirname "$0")/.."
python3 -m pip install --requirement requirements.txt --upgrade
pre-commit install
mkdir -p config