Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XML command "PlaySound" #574

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions deebot_client/commands/xml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .charge_state import GetChargeState
from .error import GetError
from .fan_speed import GetFanSpeed
from .play_sound import PlaySound
from .pos import GetPos
from .stats import GetCleanSum

Expand All @@ -21,12 +22,14 @@
"GetError",
"GetFanSpeed",
"GetPos",
"PlaySound",
]

# fmt: off
# ordered by file asc
_COMMANDS: list[type[XmlCommand]] = [
GetError,
PlaySound,
]
# fmt: on

Expand Down
14 changes: 14 additions & 0 deletions deebot_client/commands/xml/play_sound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Play sound commands."""

from __future__ import annotations

from .common import ExecuteCommand


class PlaySound(ExecuteCommand):
"""Play sound command."""

name = "PlaySound"

def __init__(self) -> None:
super().__init__({"sid": "30"})
Comment on lines +13 to +14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making the sid value configurable.

The constructor initializes the command with a hardcoded sid value of "30". This limits the flexibility of the command to play different sounds.

Consider making the sid value configurable by accepting it as a parameter in the constructor.

Apply this diff to make the sid value configurable:

-    def __init__(self) -> None:
-        super().__init__({"sid": "30"})
+    def __init__(self, sid: str = "30") -> None:
+        super().__init__({"sid": sid})
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def __init__(self) -> None:
super().__init__({"sid": "30"})
def __init__(self, sid: str = "30") -> None:
super().__init__({"sid": sid})

Loading