Add StatusField support for DeviceFeatures#746
Add StatusField support for DeviceFeatures#746allenporter wants to merge 6 commits intoPython-roborock:mainfrom
Conversation
ce3f328 to
63c052c
Compare
|
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. |
|
Like the approach - lets wait until #747 is merged in though for device info and then we can use real test. |
63c052c to
593d44c
Compare
…`APP_GET_INIT_STATUS` mock data with model-specific feature information
593d44c to
f743885
Compare
There was a problem hiding this comment.
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 newrequires_supported_featuredataclass-field metadata key. - Add
StatusField.CLEAN_PERCENTand 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; addtypes-pyyamlto 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.
| 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 |
There was a problem hiding this comment.
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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
The metadata fields need to now be moved to StatusV2. |
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.