From d2bc89bdd74ca023b32ec4266ecea5fca6cff6af Mon Sep 17 00:00:00 2001 From: Nathan Spencer Date: Tue, 22 Jul 2025 23:36:33 +0000 Subject: [PATCH] Add sleep button --- custom_components/oasis_mini/button.py | 5 +++++ custom_components/oasis_mini/pyoasismini/__init__.py | 6 ++++++ custom_components/oasis_mini/strings.json | 5 +++++ custom_components/oasis_mini/translations/en.json | 5 +++++ 4 files changed, 21 insertions(+) diff --git a/custom_components/oasis_mini/button.py b/custom_components/oasis_mini/button.py index 66e370a..19174da 100644 --- a/custom_components/oasis_mini/button.py +++ b/custom_components/oasis_mini/button.py @@ -61,6 +61,11 @@ DESCRIPTORS = ( translation_key="random_track", press_fn=play_random_track, ), + OasisMiniButtonEntityDescription( + key="sleep", + translation_key="sleep", + press_fn=lambda device: device.async_sleep(), + ), ) diff --git a/custom_components/oasis_mini/pyoasismini/__init__.py b/custom_components/oasis_mini/pyoasismini/__init__.py index 8cbec95..0858698 100644 --- a/custom_components/oasis_mini/pyoasismini/__init__.py +++ b/custom_components/oasis_mini/pyoasismini/__init__.py @@ -20,9 +20,11 @@ STATUS_CODE_MAP = { 3: "centering", 4: "playing", 5: "paused", + 6: "sleeping", 9: "error", 11: "updating", 13: "downloading", + 14: "busy", 15: "live", } @@ -331,6 +333,10 @@ class OasisMini: """Set repeat playlist.""" await self._async_command(params={"WRIREPEATJOB": 1 if repeat else 0}) + async def async_sleep(self) -> None: + """Send sleep command.""" + await self._async_command(params={"CMDSLEEP": ""}) + async def async_stop(self) -> None: """Send stop command.""" await self._async_command(params={"CMDSTOP": ""}) diff --git a/custom_components/oasis_mini/strings.json b/custom_components/oasis_mini/strings.json index 72bec6e..810efe5 100755 --- a/custom_components/oasis_mini/strings.json +++ b/custom_components/oasis_mini/strings.json @@ -41,6 +41,9 @@ "button": { "random_track": { "name": "Play random track" + }, + "sleep": { + "name": "Sleep" } }, "binary_sensor": { @@ -93,9 +96,11 @@ "centering": "Centering", "playing": "Playing", "paused": "Paused", + "sleeping": "Sleeping", "error": "Error", "updating": "Updating", "downloading": "Downloading", + "busy": "Busy", "live": "Live drawing" } } diff --git a/custom_components/oasis_mini/translations/en.json b/custom_components/oasis_mini/translations/en.json index b5bdd2c..7adf027 100755 --- a/custom_components/oasis_mini/translations/en.json +++ b/custom_components/oasis_mini/translations/en.json @@ -41,6 +41,9 @@ "button": { "random_track": { "name": "Play random track" + }, + "sleep": { + "name": "Sleep" } }, "binary_sensor": { @@ -93,9 +96,11 @@ "centering": "Centering", "playing": "Playing", "paused": "Paused", + "sleeping": "Sleeping", "error": "Error", "updating": "Updating", "downloading": "Downloading", + "busy": "Busy", "live": "Live drawing" } }