Skip to content

Commit e64030e

Browse files
committed
docs: Document metadata keys in field_metadata and is_field_supported
1 parent b2f4ddf commit e64030e

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

roborock/data/containers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,15 @@ def _attr_repr(obj: Any) -> str:
6161

6262

6363
def field_metadata(**kwargs):
64-
"""Decorator to attach metadata to a function or property.
64+
"""Decorator to attach capability check metadata to a property.
6565
6666
This attaches a `_field_metadata` dictionary to the underlying getter function,
6767
which is then preserved when decorated with `@property`.
68+
69+
Supported metadata keys:
70+
- `feature` (str): Name of a capability property on `DeviceFeaturesTrait`.
71+
- `dock_feature` (str): Name of a capability property on `RoborockDockFeatures`.
72+
- `dps` (str/int): RoborockDataProtocol ID to check against supported schema IDs.
6873
"""
6974

7075
def decorator(func):

roborock/devices/traits/v1/device_features.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ def __init__(self, product: HomeDataProduct, device_cache: DeviceCache) -> None:
7272
def is_field_supported(self, cls: type[RoborockBase], field_name: FieldNameBase) -> bool:
7373
"""Determines if the specified field is supported by this device.
7474
75-
We use the `dps` dataclass field metadata to get the `RoborockDataProtocol`
76-
integer ID and check it against the set of supported schema IDs for the
77-
device returned in the product information.
75+
We inspect the metadata defined for the field (either via dataclass field metadata
76+
or the `@field_metadata` decorator on properties). Supported checks include:
77+
78+
- `feature`: Maps to a boolean capability property on `DeviceFeatures` / `DeviceFeaturesTrait`
79+
(e.g. `is_support_water_mode`).
80+
- `dock_feature`: Maps to a boolean capability property on `RoborockDockFeatures` (e.g. `is_washable`).
81+
- `dps`: Maps to a `RoborockDataProtocol` ID checked against the product's supported schema IDs.
7882
"""
7983
if self.dock_features is None:
8084
raise ValueError("DeviceFeaturesTrait was invoked but was not fully initialized")

0 commit comments

Comments
 (0)