Skip to content

Commit

Permalink
Rename to State
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Dec 20, 2024
1 parent b3e456e commit 1b62f48
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deebot_client/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class CapabilityBaseStation:
[bool | None, auto_empty.Frequency | str | None],
auto_empty.Frequency,
]
status: CapabilityEvent[BaseStationEvent]
state: CapabilityEvent[BaseStationEvent]


@dataclass(frozen=True, kw_only=True)
Expand Down
6 changes: 3 additions & 3 deletions deebot_client/events/base_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from .base import Event as _Event

__all__ = ["BaseStationEvent", "Status"]
__all__ = ["BaseStationEvent", "State"]


@unique
class Status(IntEnum):
class State(IntEnum):
"""Enum class for all possible base station statuses."""

IDLE = 0
Expand All @@ -22,4 +22,4 @@ class Status(IntEnum):
class BaseStationEvent(_Event):
"""Base Station Event representation."""

state: Status
state: State
2 changes: 1 addition & 1 deletion deebot_client/hardware/deebot/buom7k.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
auto_empty.Frequency.SMART,
),
),
status=CapabilityEvent(BaseStationEvent, [GetStationState()]),
state=CapabilityEvent(BaseStationEvent, [GetStationState()]),
),
battery=CapabilityEvent(BatteryEvent, [GetBattery()]),
charge=CapabilityExecute(Charge),
Expand Down
2 changes: 1 addition & 1 deletion deebot_client/hardware/deebot/p95mgv.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
auto_empty.Frequency.AUTO,
),
),
status=CapabilityEvent(BaseStationEvent, [GetStationState()]),
state=CapabilityEvent(BaseStationEvent, [GetStationState()]),
),
battery=CapabilityEvent(BatteryEvent, [GetBattery()]),
charge=CapabilityExecute(Charge),
Expand Down
2 changes: 1 addition & 1 deletion deebot_client/hardware/deebot/qhe2o2.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
auto_empty.Frequency.SMART,
),
),
status=CapabilityEvent(BaseStationEvent, [GetStationState()]),
state=CapabilityEvent(BaseStationEvent, [GetStationState()]),
),
charge=CapabilityExecute(Charge),
clean=CapabilityClean(
Expand Down
6 changes: 3 additions & 3 deletions deebot_client/messages/json/station_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from typing import TYPE_CHECKING, Any

from deebot_client.events.base_station import BaseStationEvent, Status
from deebot_client.events.base_station import BaseStationEvent, State
from deebot_client.message import HandlingResult, MessageBodyDataDict

if TYPE_CHECKING:
Expand All @@ -28,14 +28,14 @@ def _handle_body_data_dict(
# "body":{"data":{"content":{"error":[],"type":1,"motionState":1},"state":1},"code":0,"msg":"ok"} - Emptying

if (state := data.get("state")) == 0:
reported_state = Status.IDLE
reported_state = State.IDLE
elif (
state == 1
and (content := data.get("content"))
and content.get("type") == 1
and content.get("motionState") == 1
):
reported_state = Status.EMPTYING
reported_state = State.EMPTYING
else:
return HandlingResult.analyse()

Expand Down
8 changes: 4 additions & 4 deletions tests/commands/json/test_station_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from deebot_client.commands.json.station_state import GetStationState
from deebot_client.events.base_station import BaseStationEvent, Status
from deebot_client.events.base_station import BaseStationEvent, State
from tests.helpers import get_request_json, get_success_body

from . import assert_command
Expand All @@ -14,14 +14,14 @@
@pytest.mark.parametrize(
("state", "additional_content", "expected"),
[
(0, {"type": 0}, Status.IDLE),
(1, {"type": 1, "motionState": 1}, Status.EMPTYING),
(0, {"type": 0}, State.IDLE),
(1, {"type": 1, "motionState": 1}, State.EMPTYING),
],
)
async def test_GetStationState(
state: int,
additional_content: dict[str, Any],
expected: Status,
expected: State,
) -> None:
json = get_request_json(
get_success_body(
Expand Down
8 changes: 4 additions & 4 deletions tests/messages/json/test_station_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

import pytest

from deebot_client.events.base_station import BaseStationEvent, Status
from deebot_client.events.base_station import BaseStationEvent, State
from deebot_client.messages.json.station_state import OnStationState
from tests.messages import assert_message


@pytest.mark.parametrize(
("state", "additional_content", "expected"),
[
(0, {"type": 0}, Status.IDLE),
(1, {"type": 1, "motionState": 1}, Status.EMPTYING),
(0, {"type": 0}, State.IDLE),
(1, {"type": 1, "motionState": 1}, State.EMPTYING),
],
)
def test_onStationState(
state: int,
additional_content: dict[str, Any],
expected: Status,
expected: State,
) -> None:
data: dict[str, Any] = {
"header": {
Expand Down

0 comments on commit 1b62f48

Please sign in to comment.