|
| 1 | +"""Deebot U2 Capabilities.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +from deebot_client.capabilities import ( |
| 6 | + Capabilities, |
| 7 | + CapabilityClean, |
| 8 | + CapabilityCleanAction, |
| 9 | + CapabilityCustomCommand, |
| 10 | + CapabilityEvent, |
| 11 | + CapabilityExecute, |
| 12 | + CapabilityLifeSpan, |
| 13 | + CapabilitySet, |
| 14 | + CapabilitySettings, |
| 15 | + CapabilitySetTypes, |
| 16 | + CapabilityStats, |
| 17 | + DeviceType, |
| 18 | +) |
| 19 | +from deebot_client.commands.json.battery import GetBattery |
| 20 | +from deebot_client.commands.json.charge import Charge |
| 21 | +from deebot_client.commands.json.charge_state import GetChargeState |
| 22 | +from deebot_client.commands.json.clean import Clean, CleanArea, GetCleanInfo |
| 23 | +from deebot_client.commands.json.clean_logs import GetCleanLogs |
| 24 | +from deebot_client.commands.json.custom import CustomCommand |
| 25 | +from deebot_client.commands.json.error import GetError |
| 26 | +from deebot_client.commands.json.fan_speed import GetFanSpeed, SetFanSpeed |
| 27 | +from deebot_client.commands.json.life_span import GetLifeSpan, ResetLifeSpan |
| 28 | +from deebot_client.commands.json.network import GetNetInfo |
| 29 | +from deebot_client.commands.json.play_sound import PlaySound |
| 30 | +from deebot_client.commands.json.stats import GetStats, GetTotalStats |
| 31 | +from deebot_client.commands.json.volume import GetVolume, SetVolume |
| 32 | +from deebot_client.commands.json.water_info import GetWaterInfo, SetWaterInfo |
| 33 | +from deebot_client.const import DataType |
| 34 | +from deebot_client.events import ( |
| 35 | + AvailabilityEvent, |
| 36 | + BatteryEvent, |
| 37 | + CleanLogEvent, |
| 38 | + CustomCommandEvent, |
| 39 | + ErrorEvent, |
| 40 | + FanSpeedEvent, |
| 41 | + FanSpeedLevel, |
| 42 | + LifeSpan, |
| 43 | + LifeSpanEvent, |
| 44 | + NetworkInfoEvent, |
| 45 | + ReportStatsEvent, |
| 46 | + StateEvent, |
| 47 | + StatsEvent, |
| 48 | + TotalStatsEvent, |
| 49 | + VolumeEvent, |
| 50 | + WaterAmount, |
| 51 | + WaterInfoEvent, |
| 52 | +) |
| 53 | +from deebot_client.models import StaticDeviceInfo |
| 54 | +from deebot_client.util import short_name |
| 55 | + |
| 56 | +from . import DEVICES |
| 57 | + |
| 58 | +DEVICES[short_name(__name__)] = StaticDeviceInfo( |
| 59 | + DataType.JSON, |
| 60 | + Capabilities( |
| 61 | + device_type=DeviceType.VACUUM, |
| 62 | + availability=CapabilityEvent( |
| 63 | + AvailabilityEvent, [GetBattery(is_available_check=True)] |
| 64 | + ), |
| 65 | + battery=CapabilityEvent(BatteryEvent, [GetBattery()]), |
| 66 | + charge=CapabilityExecute(Charge), |
| 67 | + clean=CapabilityClean( |
| 68 | + action=CapabilityCleanAction(command=Clean, area=CleanArea), |
| 69 | + log=CapabilityEvent(CleanLogEvent, [GetCleanLogs()]), |
| 70 | + ), |
| 71 | + custom=CapabilityCustomCommand( |
| 72 | + event=CustomCommandEvent, get=[], set=CustomCommand |
| 73 | + ), |
| 74 | + error=CapabilityEvent(ErrorEvent, [GetError()]), |
| 75 | + fan_speed=CapabilitySetTypes( |
| 76 | + event=FanSpeedEvent, |
| 77 | + get=[GetFanSpeed()], |
| 78 | + set=SetFanSpeed, |
| 79 | + types=( |
| 80 | + FanSpeedLevel.QUIET, |
| 81 | + FanSpeedLevel.NORMAL, |
| 82 | + FanSpeedLevel.MAX, |
| 83 | + ), |
| 84 | + ), |
| 85 | + life_span=CapabilityLifeSpan( |
| 86 | + types=( |
| 87 | + LifeSpan.BRUSH, |
| 88 | + LifeSpan.FILTER, |
| 89 | + LifeSpan.SIDE_BRUSH, |
| 90 | + ), |
| 91 | + event=LifeSpanEvent, |
| 92 | + get=[ |
| 93 | + GetLifeSpan( |
| 94 | + [ |
| 95 | + LifeSpan.BRUSH, |
| 96 | + LifeSpan.FILTER, |
| 97 | + LifeSpan.SIDE_BRUSH, |
| 98 | + ] |
| 99 | + ) |
| 100 | + ], |
| 101 | + reset=ResetLifeSpan, |
| 102 | + ), |
| 103 | + network=CapabilityEvent(NetworkInfoEvent, [GetNetInfo()]), |
| 104 | + play_sound=CapabilityExecute(PlaySound), |
| 105 | + settings=CapabilitySettings( |
| 106 | + volume=CapabilitySet(VolumeEvent, [GetVolume()], SetVolume), |
| 107 | + ), |
| 108 | + state=CapabilityEvent(StateEvent, [GetChargeState(), GetCleanInfo()]), |
| 109 | + stats=CapabilityStats( |
| 110 | + clean=CapabilityEvent(StatsEvent, [GetStats()]), |
| 111 | + report=CapabilityEvent(ReportStatsEvent, []), |
| 112 | + total=CapabilityEvent(TotalStatsEvent, [GetTotalStats()]), |
| 113 | + ), |
| 114 | + water=CapabilitySetTypes( |
| 115 | + event=WaterInfoEvent, |
| 116 | + get=[GetWaterInfo()], |
| 117 | + set=SetWaterInfo, |
| 118 | + types=( |
| 119 | + WaterAmount.LOW, |
| 120 | + WaterAmount.MEDIUM, |
| 121 | + WaterAmount.HIGH, |
| 122 | + ), |
| 123 | + ), |
| 124 | + ), |
| 125 | +) |
0 commit comments