Skip to content

fix(v1): serialize the last clean record of the clean summary - #1059

Open
hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/clean-summary-detail-dataclass
Open

hCoureau wants to merge 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/clean-summary-detail-dataclass

Conversation

@hCoureau

Copy link
Copy Markdown
Contributor

Context

CleanSummaryTrait fetches the clean summary and then the most recent clean record, and exposes the record as last_clean_record on CleanSummaryWithDetail.

Problem

CleanSummaryWithDetail declares last_clean_record but is not a dataclass, so the attribute is not a dataclass field:

  • as_dict() and device diagnostics drop the fetched record.
  • from_dict() ignores it.
  • CleanSummaryWithDetail(last_clean_record=...) raises TypeError.

Changes

  • Make CleanSummaryWithDetail a @dataclass(repr=False), keeping the shared attribute repr.
  • CleanSummaryConverter now returns plain CleanSummary objects. merge_trait_values copies every field of the converted object, so otherwise each summary refresh would reset the new field to None and a failed record fetch would lose the previous record.
  • Diagnostics now include lastCleanRecord; the snapshot is updated.

Testing

  • New test for the as_dict()/from_dict() round trip of CleanSummaryWithDetail. It fails on main, as does the updated snapshot.
  • New test that the previous record is kept when the record fetch fails. It fails if the converter change is reverted.
  • 2,363 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) with this change: as_dict() includes lastCleanRecord, from_dict(as_dict()) keeps the record, a second summary refresh keeps the same record, and the record key is present in diagnostics.
  • Keeping the previous record when the record fetch fails uses a simulated failure only.

CleanSummaryWithDetail declared last_clean_record without being a
dataclass, so as_dict() and device diagnostics dropped the fetched
record, from_dict() ignored it and the constructor rejected it.
Make the class a dataclass. The clean summary converter now returns
plain CleanSummary objects, so a summary refresh only updates the
summary fields and a failed record fetch keeps the previous record.
@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