Skip to content

fix: fix Q7 code mapping issue for workmode - #917

Merged
allenporter merged 1 commit into
mainfrom
q7_work
Aug 15, 2026
Merged

fix: fix Q7 code mapping issue for workmode#917
allenporter merged 1 commit into
mainfrom
q7_work

Conversation

@Lash-L

@Lash-L Lash-L commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Should handle: home-assistant/core#177387

adds Unknown similar to how we do elsewhere. will require a HA mapping update too

@Lash-L
Lash-L requested review from allenporter and a lite review from Copilot August 11, 2026 19:37
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
roborock/data/b01_q7/b01_q7_code_mappings.py 100.00% <100.00%> (ø)
tests/data/b01_q7/test_b01_q7_containers.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Roborock B01/Q7 status code mappings to handle an additional “working_sleep” status and to avoid breaking deserialization when encountering unknown future status codes.

Changes:

  • Add WORKING_SLEEP (code 11) to WorkStatusMapping.
  • Add an UNKNOWN fallback for unrecognized Q7 work status codes during deserialization.
  • Expand the B01/Q7 container tests to cover all known status codes, the new status code 11, and unknown-code behavior (including warning logging).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
roborock/data/b01_q7/b01_q7_code_mappings.py Extends Q7 work status mappings and adds a tolerant from_code fallback to UNKNOWN.
tests/data/b01_q7/test_b01_q7_containers.py Adds test coverage for status code mapping, status=11 parsing, and unknown status handling/logging.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +23 to +29
@classmethod
def from_code(cls, code: int) -> Self:
"""Map unrecognized Q7 statuses to UNKNOWN without failing the response."""
try:
return super().from_code(code)
except ValueError:
return cast(Self, cls.UNKNOWN)
Comment on lines +23 to +29
@classmethod
def from_code(cls, code: int) -> Self:
"""Map unrecognized Q7 statuses to UNKNOWN without failing the response."""
try:
return super().from_code(code)
except ValueError:
return cast(Self, cls.UNKNOWN)

@allenporter allenporter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Co-pilot is not wrong with its comments about this overriding the default from code behavior and interaction with optional -- but i think this makes sense to support, allowing some enums to map to an unknown value. This case also seems to make sense (allowing the warning but still working). Approving.

As we look to other cases: Do you have a sense of what enums should support this kind of fallback vs cases that should stay strict?

@allenporter
allenporter merged commit 3e0ffbd into main Aug 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants