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 new command: "VoiceAssistantState" #347

Merged
Merged
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
2 changes: 2 additions & 0 deletions deebot_client/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
StatsEvent,
TotalStatsEvent,
TrueDetectEvent,
VoiceAssistantStateEvent,
VolumeEvent,
WaterAmount,
WaterInfoEvent,
Expand Down Expand Up @@ -169,6 +170,7 @@ class CapabilitySettings:
advanced_mode: CapabilitySetEnable[AdvancedModeEvent]
carpet_auto_fan_boost: CapabilitySetEnable[CarpetAutoFanBoostEvent]
true_detect: CapabilitySetEnable[TrueDetectEvent] | None = None
voice_assistant: CapabilitySetEnable[VoiceAssistantStateEvent] | None = None
volume: CapabilitySet[VolumeEvent, int]


Expand Down
6 changes: 6 additions & 0 deletions deebot_client/commands/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from .relocation import SetRelocationState
from .stats import GetStats, GetTotalStats
from .true_detect import GetTrueDetect, SetTrueDetect
from .voice_assistant_state import GetVoiceAssistantState, SetVoiceAssistantState
from .volume import GetVolume, SetVolume
from .water_info import GetWaterInfo, SetWaterInfo
from .work_mode import GetWorkMode, SetWorkMode
Expand Down Expand Up @@ -73,6 +74,8 @@
"GetTotalStats",
"GetTrueDetect",
"SetTrueDetect",
"GetVoiceAssistantState",
"SetVoiceAssistantState",
"GetVolume",
"SetVolume",
"GetWaterInfo",
Expand Down Expand Up @@ -143,6 +146,9 @@
GetTrueDetect,
SetTrueDetect,

GetVoiceAssistantState,
SetVoiceAssistantState,

GetVolume,
SetVolume,

Expand Down
19 changes: 19 additions & 0 deletions deebot_client/commands/json/voice_assistant_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""Voice assistant state command module."""

from deebot_client.events import VoiceAssistantStateEvent

from .common import GetEnableCommand, SetEnableCommand


class GetVoiceAssistantState(GetEnableCommand):
"""Get voice assistant state command."""

name = "getVoiceAssistantState"
event_type = VoiceAssistantStateEvent


class SetVoiceAssistantState(SetEnableCommand):
"""Set voice assistant state command."""

name = "setVoiceAssistantState"
get_command = GetVoiceAssistantState
5 changes: 5 additions & 0 deletions deebot_client/events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,8 @@ class MultimapStateEvent(EnableEvent):
@dataclass(frozen=True)
class TrueDetectEvent(EnableEvent):
"""TrueDetect event."""


@dataclass(frozen=True)
class VoiceAssistantStateEvent(EnableEvent):
"""VoiceAssistantState event."""
22 changes: 22 additions & 0 deletions tests/commands/json/test_voice_assistant_state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest

from deebot_client.commands.json import GetVoiceAssistantState, SetVoiceAssistantState
from deebot_client.events import VoiceAssistantStateEvent
from tests.helpers import get_request_json, get_success_body

from . import assert_command, assert_set_enable_command


@pytest.mark.parametrize("value", [False, True])
async def test_GetTrueDetect(value: bool) -> None:
json = get_request_json(get_success_body({"enable": 1 if value else 0}))
await assert_command(
GetVoiceAssistantState(), json, VoiceAssistantStateEvent(value)
)


@pytest.mark.parametrize("value", [False, True])
async def test_SetTrueDetect(value: bool) -> None:
await assert_set_enable_command(
SetVoiceAssistantState(value), value, VoiceAssistantStateEvent
)