Repository navigation
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
CleanSummaryTraitfetches the clean summary and then the most recent clean record, and exposes the record aslast_clean_recordonCleanSummaryWithDetail.Problem
CleanSummaryWithDetaildeclareslast_clean_recordbut 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=...)raisesTypeError.Changes
CleanSummaryWithDetaila@dataclass(repr=False), keeping the shared attribute repr.CleanSummaryConverternow returns plainCleanSummaryobjects.merge_trait_valuescopies every field of the converted object, so otherwise each summary refresh would reset the new field toNoneand a failed record fetch would lose the previous record.lastCleanRecord; the snapshot is updated.Testing
as_dict()/from_dict()round trip ofCleanSummaryWithDetail. It fails onmain, as does the updated snapshot.main.Evidence
roborock.vacuum.a294, firmware 02.40.54) with this change:as_dict()includeslastCleanRecord,from_dict(as_dict())keeps the record, a second summary refresh keeps the same record, and the record key is present in diagnostics.