Repository navigation
feat(v1): add CleaningMode.VAC_THEN_MOP - #1024
paulleonartcalvo wants to merge 4 commits into
Conversation
The device reports seq_type in its get_status payload, but StatusV2 did not model it, so RoborockBase.from_dict discarded it along with every other unmatched key. The vendor app reads the same field off the same payload to derive its "clean then mop" state. Add seq_type to StatusV2 and a clean_then_mop property on StatusTrait that reports whether the current run vacuums each room fully before mopping it. It describes the run in progress rather than a persisted setting, and the device offers no setter, so it is read only here; the value travels outbound as a parameter of the cleaning command instead. Gated for reporting on is_clean_then_mop_mode_supported. Verified against a Roborock Saros 20 (roborock.vacuum.a288).
Model the app's "Vacuum then mop" choice as a fourth high-level cleaning mode, as suggested in review of Python-roborock#959, so consumers such as Home Assistant get it through cleaning_mode_options / current_cleaning_mode / set_cleaning_mode without orchestrating a separate control. - Offer VAC_THEN_MOP when is_clean_then_mop_mode_supported. - Report it when vacuum-and-mop settings run with seq_type 1. - set_cleaning_mode writes the vacuum-and-mop motor settings, then app_set_clean_sequence_type with type 1 (repeat 1 when is_ctm_with_repeat_supported); switching to another mode while it is enabled sends type 0, like the app. - clean_then_mop returns None on devices without the feature. - Replace the separate set_clean_then_mop setter with the mode, and share SEQ_TYPE_CLEAN_THEN_MOP with the per-room customize clean mode trait. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Device data from another model, in case it helps here: Qrevo S Pro ( Read-back of
One job, vacuum then mop A one-room segment clean started right after from Home Assistant ran as:
The top-level The setting did not outlive the job
This is one run on one device, so take it as a data point, not a rule. I can repeat it on current firmware, or run a specific sequence, if that helps. Done with AI assistance. Generated by Claude Code |
Lash-L
left a comment
There was a problem hiding this comment.
Automated code review by Gemini 4 Neon in Antigravity using our /review (/code-review) skill (.agents/skills/code-review/SKILL.md / AGENTS.md).
Summary by Architectural Layer
- Priority 1 — Public Trait APIs & Consumer Contracts: Clean, consumer-agnostic design. Folding clean-then-mop into
CleaningMode.VAC_THEN_MOP, gatingcleaning_mode_optionsandclean_then_moponis_clean_then_mop_mode_supported, and sharingSEQ_TYPE_CLEAN_THEN_MOPinv1_clean_modesall align withAGENTS.mdandStatusV2conventions. - Priority 2 — Data Lifecycle & State Management: 1 finding —
StatusTrait.set_cleaning_mode()updates onlyself.seq_typebefore callingself._notify_update(), leavingfan_power,water_box_mode, andmop_modestale and exposing a torncurrent_cleaning_modesnapshot to listeners until the nextrefresh()(see inline comment). - Priority 3 — Wire Protocols & App Verification (
RR_API):- Verified
app_set_clean_sequence_typepayload schema (type,fan_power,water_box_mode,mop_mode, plusrepeat: 1whentype == 1andisCtmWithRepeatSupported()),seq_type == 1status decoding, andisCleanThenMopSupported(CleanThenMopMode) /isCtmWithRepeatSupported(CtmWithRepeat) feature flags against the official Roborock app bundles (com.roborock.tanos&Qrevo Edge 3 Pro). - 1 protocol improvement: In the official app (
sendCleanWaterMopModeRpc), changingcleanThenMopModesends onlyapp_set_clean_sequence_type(notset_clean_motor_modefollowed byapp_set_clean_sequence_type), becauseapp_set_clean_sequence_typecarries the motor parameters itself (see inline comment). - Note on
@lacroixdavid1's real-device observation: on at least some firmware (a326), the robot automatically resetsseq_typeback to0at the end of a cleaning run, so theclean_then_mopdocstring's "persisted on the device" phrasing is worth keeping in mind for downstream consumers.
- Verified
- Tests & CI: Unit tests are properly colocated in
tests/devices/traits/v1/test_status.pyusing@pytest.mark.parametrize, and all CI checks pass. Adding an assertion onstatus_trait.current_cleaning_modeafterset_cleaning_mode()would cover the state-consistency finding above.
| await self.rpc_channel.send_command(RoborockCommand.APP_SET_CLEAN_SEQUENCE_TYPE, params=sequence_params) | ||
| self.seq_type = sequence_params["type"] | ||
| self._notify_update() |
There was a problem hiding this comment.
Priority 2 (Data Lifecycle & State Management): Partial local state mutation before _notify_update()
Updating only self.seq_type and calling self._notify_update() while leaving self.fan_power, self.water_box_mode, and self.mop_mode at their pre-call values exposes an inconsistent current_cleaning_mode to update listeners until the next refresh():
- Switching
VAC_THEN_MOP(water_box_mode=235, seq_type=1) ->VACUUM(water_box_mode=200, seq_type=0):self.seq_typebecomes0whilewater_box_modestays235, so listeners readcurrent_cleaning_mode == CleaningMode.VAC_AND_MOPinstead ofVACUUM. - Switching
VACUUM(water_box_mode=200, seq_type=0) ->VAC_THEN_MOP:self.seq_typebecomes1whilewater_box_modestays200, so listeners readclean_then_mop is Truewhilecurrent_cleaning_modeis stillCleaningMode.VACUUM.
Suggested fix: Update all written motor fields alongside seq_type before notifying listeners (matching the official app's sendCleanWaterMopModeRpc, which updates cleanThenMop, fanPower, waterBoxMode, and mopMode together):
motor = motor_params[0]
self.fan_power = motor["fan_power"]
self.water_box_mode = motor["water_box_mode"]
if "mop_mode" in motor:
self.mop_mode = motor["mop_mode"]
# (and self.seq_type = sequence_params["type"] when APP_SET_CLEAN_SEQUENCE_TYPE is sent)
self._notify_update()| await self.rpc_channel.send_command(RoborockCommand.SET_CLEAN_MOTOR_MODE, params=motor_params) | ||
| if not self._device_features_trait.is_clean_then_mop_mode_supported: | ||
| return | ||
| if mode != CleaningMode.VAC_THEN_MOP and not self.clean_then_mop: | ||
| return | ||
| sequence_params = get_clean_sequence_parameters(mode, motor_params[0], self._device_features_trait) | ||
| await self.rpc_channel.send_command(RoborockCommand.APP_SET_CLEAN_SEQUENCE_TYPE, params=sequence_params) |
There was a problem hiding this comment.
Priority 3 (Wire Protocol): app_set_clean_sequence_type replaces set_clean_motor_mode in the official app
In the official Roborock app (sendCleanWaterMopModeRpc), when cleanThenMopMode changes, the app sends only app_set_clean_sequence_type (which already carries fan_power, water_box_mode, mop_mode, and optional repeat: 1) and skips set_clean_motor_mode. It only sends set_clean_motor_mode when the clean-then-mop state is unchanged.
Sending both RPCs adds an extra round-trip and introduces a partial-failure window if SET_CLEAN_MOTOR_MODE succeeds and APP_SET_CLEAN_SEQUENCE_TYPE fails or times out. Consider branching so only one command is sent:
mode = resolve_cleaning_mode(cleaning_mode)
motor_params = get_cleaning_mode_parameters(mode, self._device_features_trait)
update_sequence = self._device_features_trait.is_clean_then_mop_mode_supported and (
mode == CleaningMode.VAC_THEN_MOP or bool(self.clean_then_mop)
)
if update_sequence:
sequence_params = get_clean_sequence_parameters(mode, motor_params[0], self._device_features_trait)
await self.rpc_channel.send_command(RoborockCommand.APP_SET_CLEAN_SEQUENCE_TYPE, params=sequence_params)
self.seq_type = sequence_params["type"]
else:
await self.rpc_channel.send_command(RoborockCommand.SET_CLEAN_MOTOR_MODE, params=motor_params)|
Hi, and thanks for working on this. I own a Roborock Qrevo Edge 2 and was hitting the same problem in Home Assistant: the cleaning mode shows as Device: Roborock Qrevo Edge 2 ( What the official app sends This is the same shape as the payload in the PR description. The app also sent Read-back of With the robot docked, I sent the command above by hand with the same fan, water and mop values:
Things that do not work
So Not tested: a full cleaning run with I can attach the decoded frames (with my device key and IDs removed) if that helps. |
Builds on #959 and implements the direction @allenporter suggested in this review comment: fold "clean then mop" into
CleaningModeas a fourth mode, so consumers like Home Assistant get it through the existing cleaning mode select instead of a separate control. Closes #914.The first three commits are @klowdo's from #959, rebased onto
mainunchanged. The last commit adds the mode on top. Happy to fold this into #959 instead if that is easier.Changes
CleaningMode.VAC_THEN_MOP("vac_then_mop"), offered inget_cleaning_mode_options()whenis_clean_then_mop_mode_supported.get_current_cleaning_mode()takes an optionalseq_typeand reportsVAC_THEN_MOPfor vacuum-and-mop settings withseq_type == 1;StatusTrait.current_cleaning_modepasses it through.StatusTrait.set_cleaning_mode():VAC_THEN_MOP: writes the vacuum-and-mop motor settings withset_clean_motor_mode, thenapp_set_clean_sequence_typewithtype: 1and the same motor values (repeat: 1whenis_ctm_with_repeat_supported).type: 0after the motor write, like the app. Nothing extra is sent when it is already off or unsupported.clean_then_mopreturnsNoneon devices without the feature (point 3 of the review).set_clean_then_mop()setter from feat(v1): expose clean-then-mop status from the device #959, since the mode now covers it and a standalone setter can produce the conflictingtype: 1withwater_box_mode: 200case from the review. Easy to restore if you would rather keep it.SEQ_TYPE_CLEAN_THEN_MOPnow lives inv1_clean_modesand is shared with the per-roomCustomizeCleanModeTrait(feat(v1): expose per-room clean-then-mop via customize clean mode #984).Device testing
Qrevo Edge 3 Pro (
roborock.vacuum.a296, water slide,isCleanThenMopModeSupportedandisCtmWithRepeatSupportedboth true):app_set_clean_sequence_type{"type": 1, "water_box_mode": 248, "mop_mode": 300, "fan_power": 102, "repeat": 1}. The robot answeredok.seq_typeback fromget_status(verified on the Saros 20 in feat(v1): expose clean-then-mop status from the device #959).uv run pytest(2301 passed) anduv run pre-commit run --all-filespass.🤖 Generated with Claude Code