Skip to content
Closed
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
7 changes: 5 additions & 2 deletions deebot_client/commands/json/map/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ def _handle_rooms_subsets(
subsets: list[list[str]],
map_id: str,
) -> HandlingResult:
# there are two versions of this message, depending on the number of values
if subsets and len(subsets[0]) == 10:
# There are currently two known room subset formats:
# - 10 fields: standard V2 format
# - 11 fields: newer models (e.g. X11) with an extra trailing field
if subsets and len(subsets[0]) in (10, 11):
# subset values
# 1 -> id
# 2 -> name
Expand All @@ -285,6 +287,7 @@ def _handle_rooms_subsets(
# 8 -> room clean configs as '<count>-<speed>-<water>'
# 9 -> unknown
# 10 -> floor type
# 11 -> unknown extra trailing field (seen on newer models, e.g. X11)

# coordinates are sent in the MapInfo_V2 message
event_bus.notify(
Expand Down
289 changes: 289 additions & 0 deletions deebot_client/hardware/o073ti.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,289 @@
"""Deebot DEEBOT X11 PRO OMNI Capabilities."""

from __future__ import annotations

from deebot_client.capabilities import (
Capabilities,
CapabilityClean,
CapabilityCleanAction,
CapabilityCustomCommand,
CapabilityEvent,
CapabilityExecute,
CapabilityExecuteTypes,
CapabilityLifeSpan,
CapabilityMap,
CapabilityNumber,
CapabilitySet,
CapabilitySetEnable,
CapabilitySettings,
CapabilitySetTypes,
CapabilityStation,
CapabilityStats,
CapabilityWater,
DeviceType,
)
from deebot_client.commands import StationAction
from deebot_client.commands.json import station_action
from deebot_client.commands.json.advanced_mode import GetAdvancedMode, SetAdvancedMode
from deebot_client.commands.json.auto_empty import GetAutoEmpty, SetAutoEmpty
from deebot_client.commands.json.battery import GetBattery
from deebot_client.commands.json.carpet import (
GetCarpetAutoFanBoost,
SetCarpetAutoFanBoost,
)
from deebot_client.commands.json.charge import Charge
from deebot_client.commands.json.charge_state import GetChargeState
from deebot_client.commands.json.child_lock import GetChildLock, SetChildLock
from deebot_client.commands.json.clean import CleanAreaV2, CleanV2
from deebot_client.commands.json.clean_count import GetCleanCount, SetCleanCount
from deebot_client.commands.json.clean_logs import GetCleanLogs
from deebot_client.commands.json.clean_preference import (
GetCleanPreference,
SetCleanPreference,
)
from deebot_client.commands.json.continuous_cleaning import (
GetContinuousCleaning,
SetContinuousCleaning,
)
from deebot_client.commands.json.custom import CustomCommand
from deebot_client.commands.json.efficiency import GetEfficiencyMode, SetEfficiencyMode
from deebot_client.commands.json.error import GetError
from deebot_client.commands.json.fan_speed import GetFanSpeed, SetFanSpeed
from deebot_client.commands.json.life_span import GetLifeSpan, ResetLifeSpan
from deebot_client.commands.json.map import (
GetCachedMapInfo,
GetMajorMap,
GetMapInfoV2,
GetMapSetV2,
GetMapTrace,
GetMinorMap,
SetMajorMap,
)
from deebot_client.commands.json.multimap_state import (
GetMultimapState,
SetMultimapState,
)
from deebot_client.commands.json.network import GetNetInfo
from deebot_client.commands.json.ota import GetOta, SetOta
from deebot_client.commands.json.play_sound import PlaySound
from deebot_client.commands.json.pos import GetPos
from deebot_client.commands.json.relocation import SetRelocationState
from deebot_client.commands.json.stats import GetStats, GetTotalStats
from deebot_client.commands.json.sweep_mode import GetSweepMode, SetSweepMode
from deebot_client.commands.json.true_detect import GetTrueDetect, SetTrueDetect
from deebot_client.commands.json.voice_assistant_state import (
GetVoiceAssistantState,
SetVoiceAssistantState,
)
from deebot_client.commands.json.volume import GetVolume, SetVolume
from deebot_client.commands.json.water_info import GetWaterInfo, SetWaterInfo
from deebot_client.commands.json.work_mode import GetWorkMode, SetWorkMode
from deebot_client.commands.json.work_state import GetWorkState
from deebot_client.const import DataType
from deebot_client.events import (
AdvancedModeEvent,
AvailabilityEvent,
BatteryEvent,
CachedMapInfoEvent,
CarpetAutoFanBoostEvent,
ChildLockEvent,
CleanCountEvent,
CleanLogEvent,
CleanPreferenceEvent,
ContinuousCleaningEvent,
CustomCommandEvent,
EfficiencyModeEvent,
ErrorEvent,
FanSpeedEvent,
FanSpeedLevel,
LifeSpan,
LifeSpanEvent,
MajorMapEvent,
MapChangedEvent,
MapTraceEvent,
MultimapStateEvent,
NetworkInfoEvent,
OtaEvent,
PositionsEvent,
ReportStatsEvent,
RoomsEvent,
StateEvent,
StationEvent,
StatsEvent,
SweepModeEvent,
TotalStatsEvent,
TrueDetectEvent,
VoiceAssistantStateEvent,
VolumeEvent,
WorkMode,
WorkModeEvent,
auto_empty,
water_info,
)
from deebot_client.events.auto_empty import AutoEmptyEvent
from deebot_client.events.efficiency_mode import EfficiencyMode
from deebot_client.models import StaticDeviceInfo


def get_device_info() -> StaticDeviceInfo:
"""Get device info for this model."""
return StaticDeviceInfo(
DataType.JSON,
Capabilities(
device_type=DeviceType.VACUUM,
availability=CapabilityEvent(
AvailabilityEvent, [GetBattery(is_available_check=True)]
),
battery=CapabilityEvent(BatteryEvent, [GetBattery()]),
charge=CapabilityExecute(Charge),
clean=CapabilityClean(
action=CapabilityCleanAction(command=CleanV2, area=CleanAreaV2),
continuous=CapabilitySetEnable(
ContinuousCleaningEvent,
[GetContinuousCleaning()],
SetContinuousCleaning,
),
count=CapabilitySet(CleanCountEvent, [GetCleanCount()], SetCleanCount),
log=CapabilityEvent(CleanLogEvent, [GetCleanLogs()]),
preference=CapabilitySetEnable(
CleanPreferenceEvent, [GetCleanPreference()], SetCleanPreference
),
work_mode=CapabilitySetTypes(
event=WorkModeEvent,
get=[GetWorkMode()],
set=SetWorkMode,
types=(
WorkMode.MOP,
WorkMode.MOP_AFTER_VACUUM,
WorkMode.VACUUM,
WorkMode.VACUUM_AND_MOP,
),
),
),
custom=CapabilityCustomCommand(
event=CustomCommandEvent, get=[], set=CustomCommand
),
error=CapabilityEvent(ErrorEvent, [GetError()]),
fan_speed=CapabilitySetTypes(
event=FanSpeedEvent,
get=[GetFanSpeed()],
set=SetFanSpeed,
types=(
FanSpeedLevel.QUIET,
FanSpeedLevel.NORMAL,
FanSpeedLevel.MAX,
FanSpeedLevel.MAX_PLUS,
),
),
life_span=CapabilityLifeSpan(
types=(
LifeSpan.BRUSH,
LifeSpan.FILTER,
LifeSpan.HAND_FILTER,
LifeSpan.SIDE_BRUSH,
LifeSpan.UNIT_CARE,
LifeSpan.CLEANING_SOLUTION,
LifeSpan.SEWAGE_BOX,
),
event=LifeSpanEvent,
get=[
GetLifeSpan(
[
LifeSpan.BRUSH,
LifeSpan.FILTER,
LifeSpan.HAND_FILTER,
LifeSpan.SIDE_BRUSH,
LifeSpan.CLEANING_SOLUTION,
LifeSpan.SEWAGE_BOX,
]
)
],
reset=ResetLifeSpan,
),
map=CapabilityMap(
cached_info=CapabilityEvent(CachedMapInfoEvent, [GetCachedMapInfo()]),
changed=CapabilityEvent(MapChangedEvent, []),
info=CapabilityExecute(GetMapInfoV2),
major=CapabilitySet(MajorMapEvent, [GetMajorMap()], SetMajorMap),
minor=CapabilityExecute(GetMinorMap),
multi_state=CapabilitySetEnable(
MultimapStateEvent, [GetMultimapState()], SetMultimapState
),
position=CapabilityEvent(PositionsEvent, [GetPos()]),
relocation=CapabilityExecute(SetRelocationState),
rooms=CapabilityEvent(RoomsEvent, [GetCachedMapInfo()]),
set=CapabilityExecute(GetMapSetV2),
trace=CapabilityEvent(MapTraceEvent, [GetMapTrace()]),
),
network=CapabilityEvent(NetworkInfoEvent, [GetNetInfo()]),
play_sound=CapabilityExecute(PlaySound),
settings=CapabilitySettings(
advanced_mode=CapabilitySetEnable(
AdvancedModeEvent, [GetAdvancedMode()], SetAdvancedMode
),
carpet_auto_fan_boost=CapabilitySetEnable(
CarpetAutoFanBoostEvent,
[GetCarpetAutoFanBoost()],
SetCarpetAutoFanBoost,
),
child_lock=CapabilitySetEnable(
ChildLockEvent, [GetChildLock()], SetChildLock
),
efficiency_mode=CapabilitySetTypes(
event=EfficiencyModeEvent,
get=[GetEfficiencyMode()],
set=SetEfficiencyMode,
types=(
EfficiencyMode.ENERGY_EFFICIENT_MODE,
EfficiencyMode.STANDARD_MODE,
),
),
ota=CapabilitySetEnable(OtaEvent, [GetOta()], SetOta),
sweep_mode=CapabilitySetEnable(
SweepModeEvent, [GetSweepMode()], SetSweepMode
),
true_detect=CapabilitySetEnable(
TrueDetectEvent, [GetTrueDetect()], SetTrueDetect
),
voice_assistant=CapabilitySetEnable(
VoiceAssistantStateEvent,
[GetVoiceAssistantState()],
SetVoiceAssistantState,
),
volume=CapabilitySet(VolumeEvent, [GetVolume()], SetVolume),
),
state=CapabilityEvent(StateEvent, [GetChargeState(), GetWorkState()]),
station=CapabilityStation(
action=CapabilityExecuteTypes(
station_action.StationAction, types=(StationAction.EMPTY_DUSTBIN,)
),
auto_empty=CapabilitySetTypes(
event=AutoEmptyEvent,
get=[GetAutoEmpty()],
set=SetAutoEmpty,
types=(
auto_empty.Frequency.AUTO,
auto_empty.Frequency.SMART,
),
),
state=CapabilityEvent(StationEvent, [GetWorkState()]),
),
stats=CapabilityStats(
clean=CapabilityEvent(StatsEvent, [GetStats()]),
report=CapabilityEvent(ReportStatsEvent, []),
total=CapabilityEvent(TotalStatsEvent, [GetTotalStats()]),
),
water=CapabilityWater(
amount=CapabilityNumber(
event=water_info.WaterCustomAmountEvent,
get=[GetWaterInfo()],
set=lambda custom_amount: SetWaterInfo(custom_amount=custom_amount),
min=0,
max=50,
),
mop_attached=CapabilityEvent(
water_info.MopAttachedEvent, [GetWaterInfo()]
),
),
),
)
52 changes: 52 additions & 0 deletions tests/commands/json/map/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,58 @@ async def test_getMapSetV2_rooms_v2() -> None:
)


async def test_getMapSetV2_rooms_v2_with_extra_fields() -> None:
"""Test newer room subset format with an extra trailing field."""
mid = "2085019938"
msid = "1625821963"
set_type = MapSetType.ROOMS
subsets_comp = (
"KLUv/WBkAc0IAOJPLSVwt0kH/P+xqqpeMAKDNMF+IYzpZcULRMLOmxEjlmxK25T5/"
"+EFByTXHVmYrmkHzzlN4HAOYtEMCvcFLQwTVJj3THeHYTQNRuGuJIkqQXRfd/eYh2"
"kU7iwlrjtjmI5TvLY4EBIO1yRI3dV9SXfFY57HOQH3xRBUMN0CgrtCTK0FFUweIxU"
"ESfe8L1T35P48piEOlzhc07QBQw+je7of90SE6b4y8b4Ycl/Y3TGOS7zWALijDYYo"
"IFACQQJifKBZ0ZVL24gxxwvXGEPiXtQyuBuQSmEYC65AkaoHGmuccJCiEPHAzaMd3"
"dFXzof7/Q3eAmkP20uBHNo2puBeRgGG/yWN4NzRzBp0xgdWrlYOZ/D23CCeM84E"
)
subsets = [0, 1, 2, 3, 5, 6, 7, 8, 9]
rooms_names = [
"Buanderie",
"Salle de bains",
"Salon",
"Wc",
"Dressing",
"Salle \u00e0 manger",
"Cuisine",
"Couloir",
"Chambre Parentale",
]
json, firmware_event = get_request_json(
get_success_body(
{
"type": set_type,
"mid": mid,
"msid": msid,
"batid": "gfhhhi",
"serial": 1,
"index": 1,
"subsets": subsets_comp,
"infoSize": 612,
}
)
)
rooms = [
Room(room_name, subset, "")
for subset, room_name in zip(subsets, rooms_names, strict=False)
]
events = [firmware_event, RoomsEvent(mid, rooms)]

await assert_command(
GetMapSetV2(mid, set_type),
json,
events,
)


async def test_getMapTrace() -> None:
start = 0
total = 160
Expand Down