Skip to content

Add StatusField support for DeviceFeatures#746

Draft
allenporter wants to merge 6 commits intoPython-roborock:mainfrom
allenporter:device-features
Draft

Add StatusField support for DeviceFeatures#746
allenporter wants to merge 6 commits intoPython-roborock:mainfrom
allenporter:device-features

Conversation

@allenporter
Copy link
Contributor

Add support for checking if a field is supported based on the device features status. This adds support for clean percent, though we don't currently have a device info that supports it.

Copilot AI review requested due to automatic review settings January 16, 2026 15:26
@allenporter allenporter requested review from Lash-L and removed request for Copilot January 16, 2026 15:27
@allenporter
Copy link
Contributor Author

Curious to get input on direction for this and if it makes sense. I think next step would be to add some fake device infos or another one off test. If you happen to know which devices support this we can try to make one from user reports diagnostic data.

@Lash-L
Copy link
Collaborator

Lash-L commented Jan 17, 2026

Like the approach - lets wait until #747 is merged in though for device info and then we can use real test.

@allenporter allenporter marked this pull request as ready for review March 22, 2026 20:05
Copilot AI review requested due to automatic review settings March 22, 2026 20:05
Copy link
Contributor

Copilot AI left a comment

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 aims to extend V1 field support detection so DeviceFeaturesTrait.is_field_supported() can determine support not only via product schema codes, but also via feature flags derived from APP_GET_INIT_STATUS (with clean_percent as the first consumer).

Changes:

  • Extend DeviceFeaturesTrait.is_field_supported() to honor a new requires_supported_feature dataclass-field metadata key.
  • Add StatusField.CLEAN_PERCENT and introduce a _requires_supported_feature(...) helper for status fields.
  • Update test fixtures to optionally pull init-status feature flags from device_info.yaml, and update snapshots accordingly; add types-pyyaml to pre-commit mypy hook deps.

Reviewed changes

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

Show a summary per file
File Description
tests/mock_data.py Loads device_info.yaml and builds a per-model init-status override dict for tests.
tests/devices/traits/v1/fixtures.py Adds a fixture to provide model-specific APP_GET_INIT_STATUS test data and wires it into discovery.
tests/devices/traits/v1/__snapshots__/test_device_features.ambr Snapshot update to include clean_percent support results.
roborock/devices/traits/v1/device_features.py Adds requires_supported_feature handling in is_field_supported() and tweaks initialization.
roborock/device_features.py Adjusts from_feature_flags() return type to Self (typing cleanup).
roborock/data/v1/v1_containers.py Adds StatusField.CLEAN_PERCENT and introduces _requires_supported_feature; annotates Status.clean_percent.
.pre-commit-config.yaml Adds types-pyyaml for mypy in pre-commit.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 176 to 181
distance_off: int | None = None
in_warmup: int | None = None
dry_status: int | None = _requires_schema_code("drying_status", default=None)
dry_status: int | None = _requires_schema_code("drying_status")
rdt: int | None = None
clean_percent: int | None = None
clean_percent: int | None = _requires_supported_feature("is_support_clean_estimate")
rss: int | None = None
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

requires_supported_feature metadata is added to the deprecated Status dataclass, but StatusTrait (used in tests and the V1 status implementation) inherits StatusV2, where clean_percent still has no metadata. As a result, DeviceFeaturesTrait.is_field_supported(StatusTrait, StatusField.CLEAN_PERCENT) will continue to return True unconditionally, so the new feature-based support check isn’t actually applied. The metadata (or an equivalent mechanism) likely needs to live on StatusV2 (or whatever dataclass is passed to is_field_supported) for this to work as intended.

Copilot uses AI. Check for mistakes.
@allenporter allenporter marked this pull request as draft March 22, 2026 20:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@allenporter
Copy link
Contributor Author

The metadata fields need to now be moved to StatusV2.

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