Skip to content

fix(v1): aggregate multi-phase cleaning records - #1058

Open
hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/multiphase-clean-record-totals
Open

hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/multiphase-clean-record-totals

Conversation

@hCoureau

Copy link
Copy Markdown
Contributor

Context

get_clean_record can return a list with one record per phase of a clean, for example vacuum then mop. CleanRecordConverter is meant to combine the phases into one CleanRecord. #1034 noted multi-phase aggregation as a separate existing issue; this addresses it.

Problem

The converter combined the phases by assigning to CleanRecord.begin_datetime, which is a read-only property. The resulting AttributeError was swallowed by a broad except, so callers got the last phase's duration, area, counters and start_type instead of totals for the whole clean.

Changes

  • Build the combined record with dataclasses.replace on the last phase. It keeps the first phase's begin and start_type and sums duration, area, avoid_count and wash_count across phases, which is what the existing code was trying to do.
  • A field that no phase reports stays None and is not filled in as 0.
  • Remove the broad except Exception. A reply that mixes structured and list-form phases now raises RoborockParsingException.

Testing

  • New tests: a three-phase record, including a counter reported by only one phase and one reported by none, and two mixed-format replies. All three cases fail without the fix.
  • 2,364 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), 20 single-phase records read through this branch parse to the same duration, area, begin and end as the raw replies, so the single-phase path is unchanged on hardware.
  • The multi-phase and mixed-format payloads are synthetic. Every record I have seen from this device has one phase, including vacuum-and-mop runs with mop washes.

Combining a multi-phase clean record assigned to the read-only
begin_datetime property. The error was swallowed, so callers got the
last phase's duration, area and counters and its start type. Build the
record from the last phase with the first phase's begin and start type,
and sum duration, area and counters across phases; fields no phase
reports stay unset. Replies mixing record formats now raise a parsing
error.
@Lash-L Lash-L added Small PR Small pull request (<200 lines) bug Something isn't working V1 V1 platform labels Nov 18, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Small PR Small pull request (<200 lines) V1 V1 platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants