Skip to content

fix(v1): decode unrecognized error and status codes as unknown - #1057

Merged
allenporter merged 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/unknown-v1-status-codes
Nov 22, 2026
Merged

allenporter merged 1 commit into
Python-roborock:mainfrom
hCoureau:submit/fix/unknown-v1-status-codes

Conversation

@hCoureau

@hCoureau hCoureau commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Context

RoborockEnum._missing_ decodes a code the library does not know as the enum's unknown member when it has one, and as the first member otherwise. The enum conformance test keeps a baseline of enums that still lack unknown.

Problem

RoborockErrorCode, RoborockDockErrorCode, RoborockInCleaning, RoborockFinishReason, RoborockCleanType and RoborockStartType have no unknown member, so an unrecognized code is reported as a real value. An unrecognized robot or dock error reads as none/ok, in_cleaning: 4 reads as complete (#929), and finish reason 78 reads as manual_interrupt (#523).

Changes

  • Add unknown = -1 to these six enums and remove them from the conformance baseline.
  • StatusTrait.resolve_error() called without a code skips an unknown dock or robot error, so it never sends -1. This keeps the previous behaviour, where such codes decoded as ok/none and nothing was sent.
  • No named codes are added. RoborockInCleaning is missing code 4 (a298) #929 and Missing RoborockFinishReason code: 78 - defaulting to 21 #523 ask for those; this only stops the codes being misreported.
  • keys() and as_dict() on these enums now include unknown, so consumers that build option lists from them will see the extra value.

Testing

  • New tests for the unknown-code fallback of all six enums. They fail without the enum change, as do the six conformance cases.
  • New tests for resolve_error(): an unknown dock error falls through to the robot error, and nothing is sent when only an unknown error is reported. They fail without the status.py guard.
  • 2,376 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), known codes still decode to their names with this change: error 0, dock error 0, in_cleaning 3, start type 2, clean types 1, 2 and 3, and finish reasons 43, 54 and 56.
  • Decoding an unrecognized code and resolve_error() skipping it use simulated codes only. My device reports no unmapped code, and resolve_error was not sent to it.

Related to #929 and #523.

@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

Clean, well-scoped fix with no blocking or non-blocking findings — ready to approve.

Priority 1: Public Trait APIs & Consumer Contracts

  • RoborockErrorCode, RoborockDockErrorCode, RoborockInCleaning, RoborockFinishReason, RoborockCleanType, and RoborockStartType now expose unknown = -1, bringing keys(), as_dict(), and Status.error_code_name in line with sibling resilient enums (RoborockStateCode, RoborockChargeStatus, RoborockDockTypeCode).
  • StatusTrait.resolve_error() preserves its public signature and explicit error_code override behavior while preventing unrecognized codes from being sent as -1.

Priority 2: Data Lifecycle & State Management

  • Checked all usages of the six enum fields across roborock/ for truthiness regressions now that unknown codes decode to -1 (truthy) rather than 0 (ok/none/complete, falsy). StatusTrait.resolve_error() is the only affected control-flow path and is properly guarded so an unknown dock error falls through to a known robot error and an unknown robot error is a no-op.
  • StatusTrait.update_from_dps() continues to convert ERROR_CODE cleanly via RoborockBase.convert_dict.

Priority 3: Wire Protocols, Codecs & Resilient Enums

  • Cross-verified against the V1 app protocol (com.roborock.tanos): wire codes for all six fields are non-negative integers, so unknown = -1 cannot collide with valid firmware values.
  • All six enums are removed from KNOWN_ENUMS_MISSING_UNKNOWN in tests/conformance/test_enum_conformance.py, permanently enforcing their fallback contract.

Tests & CI

  • Parametrized unit tests are properly colocated in tests/data/test_code_mappings.py and tests/devices/traits/v1/test_status.py, covering all six enum fallbacks and resolve_error() skip/fallthrough cases.
  • All CI checks pass on 94cfa63.

@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
RoborockErrorCode, RoborockDockErrorCode, RoborockInCleaning,
RoborockFinishReason, RoborockCleanType and RoborockStartType had no
unknown member, so an unrecognized code fell back to the first member:
an unmapped robot or dock error read as none/ok and an unmapped
in_cleaning value as complete. These enums now decode such codes as
unknown, and StatusTrait.resolve_error() without an explicit code skips
an unknown error instead of sending -1.
@hCoureau
hCoureau force-pushed the submit/fix/unknown-v1-status-codes branch from 94cfa63 to ac17429 Compare November 21, 2026 21:36
@allenporter
allenporter merged commit 2527d9a into Python-roborock:main Nov 22, 2026
9 checks passed
@hCoureau
hCoureau deleted the submit/fix/unknown-v1-status-codes branch November 22, 2026 13:03
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