Skip to content

Commit

Permalink
Add new command: "VoiceAssistantState" (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
MVladislav authored Nov 16, 2023
1 parent 19a9684 commit 8f6e947
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
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 @@ -173,6 +174,7 @@ class CapabilitySettings:
CapabilitySetTypes[EfficiencyModeEvent, EfficiencyMode] | None
) = None
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 @@ -31,6 +31,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 @@ -76,6 +77,8 @@
"GetTotalStats",
"GetTrueDetect",
"SetTrueDetect",
"GetVoiceAssistantState",
"SetVoiceAssistantState",
"GetVolume",
"SetVolume",
"GetWaterInfo",
Expand Down Expand Up @@ -149,6 +152,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 @@ -225,3 +225,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
)

0 comments on commit 8f6e947

Please sign in to comment.