Skip to content

fix(v1): update wash towel mode after setting it - #1060

Merged
allenporter merged 2 commits into
Python-roborock:mainfrom
hCoureau:submit/fix/wash-towel-mode-local-state
Nov 22, 2026
Merged

allenporter merged 2 commits into
Python-roborock:mainfrom
hCoureau:submit/fix/wash-towel-mode-local-state

Conversation

@hCoureau

Copy link
Copy Markdown
Contributor

Context

V1TraitMixin expects a setter to leave the trait's own state current, either by updating it optimistically or by refreshing. The other V1 setters, such as child_lock, led_status, mop_dryer and volume, do this.

Problem

WashTowelModeTrait.set_wash_towel_mode() sends set_wash_towel_mode but does not update wash_mode. After a successful set the trait keeps reporting the previous mode until the next refresh().

Changes

Testing

  • The existing test_set_wash_towel_mode now also asserts the trait state. The new assertion fails on unchanged code.
  • 2,361 tests passed on each of Python 3.11 and 3.14, on current main.
  • pre-commit, commitlint and source/wheel builds passed.

Evidence

On a Qrevo 2 Pro (roborock.vacuum.a294, firmware 02.40.54), for each wash mode the library offers on this device (light 0, balanced 1, deep 2, super_deep 8):

  • Before this change, the dock accepted the set and get_wash_towel_mode returned the new value, but wash_mode still held the previous one.
  • With this change, the same run reports the new mode locally after each set.

The original mode was restored afterwards.

WashTowelModeTrait.set_wash_towel_mode sent the command but left wash_mode
unchanged, so the trait kept reporting the previous mode until the next
refresh. Update wash_mode optimistically after the command, like the other
V1 trait setters.
@Lash-L Lash-L added Small PR Small pull request (<200 lines) bug Something isn't working V1 V1 platform labels Nov 18, 2026

@Lash-L Lash-L left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (roborock/devices/traits/v1/wash_towel_mode.py): Clean. WashTowelModeTrait.set_wash_towel_mode(self, mode: WashTowelModes) updates self.wash_mode with the typed WashTowelModes enum value, matching WashTowelMode.wash_mode: WashTowelModes | None and refresh() deserialization with no API surface changes or untyped boundaries.
  • Priority 2 — Data Lifecycle & State Management (roborock/devices/traits/v1/wash_towel_mode.py): Clean. The optimistic update after await self.rpc_channel.send_command(...) satisfies V1TraitMixin's setter contract and matches sibling single-field V1 setters (ChildLockTrait, LedStatusTrait, FlowLedStatusTrait, MopDryerTrait, SoundVolumeTrait, ValleyElectricityTimerTrait, DoNotDisturbTrait). Because the assignment runs after send_command awaits, failed RPC calls leave self.wash_mode unchanged.
  • Priority 3 — Wire Protocols, Codecs & Resilient Enums: No wire protocol or codec changes; set_wash_towel_mode ({"wash_mode": mode.code}) maps 1:1 to the single-field WashTowelMode model.
  • Tests & CI (tests/devices/traits/v1/test_wash_towel_mode.py): Clean. Colocated assertion added directly to the existing parametrized test_set_wash_towel_mode test, verifying the public wash_mode attribute. All CI checks pass.

Verdict

No findings survived adversarial self-check. This PR is tightly scoped, consistent with sibling V1 traits, and clean and ready to approve.

@Lash-L Lash-L added /review run Code review skill (/review) has been run Passed /review Passed the /review skill check labels Nov 21, 2026
@allenporter

Copy link
Copy Markdown
Contributor

I'm not so sure how i feel about this, but OK. I think we may want to have the opinion that commands do start a refresh after, and/or rely on an ayns update, but seems ok to do this for now.

@allenporter
allenporter merged commit e1220ee into Python-roborock:main Nov 22, 2026
9 checks passed
@hCoureau
hCoureau deleted the submit/fix/wash-towel-mode-local-state branch November 22, 2026 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Passed /review Passed the /review skill check /review run Code review skill (/review) has been run Small PR Small pull request (<200 lines) V1 V1 platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants