Repository navigation
feat(v1): add collision avoidance traits - #1089
Merged
allenporter merged 1 commit intoNov 25, 2026
Merged
allenporter merged 1 commit into
allenporter merged 1 commit into
Conversation
get_collision_avoid_status and set_collision_avoid_status had no typed trait, so consumers had to send raw commands to read or change the setting. Add CollisionAvoidanceTrait, an on/off switch for devices that report is_avoid_collision_supported, and CollisionAvoidanceModeTrait for devices that report is_two_gears_no_collision_supported. The mode trait decodes the value to CollisionAvoidanceMode (1 high_coverage, 2 less_collision, other values unknown) and sets it with set_collision_avoidance_mode(), which rejects unknown. Two-level devices do not get the switch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
hCoureau
force-pushed
the
submit/feat/collision-avoidance-setting
branch
from
November 23, 2026 23:33
1b9294a to
e29a563
Compare
This was referenced Nov 24, 2026
allenporter
approved these changes
Nov 25, 2026
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds typed V1 traits for the collision avoidance setting (
get_collision_avoid_status/set_collision_avoid_status), which previously could only be read or changed by sending raw commands.CollisionAvoidanceTrait(device.v1_properties.collision_avoidance): an on/off switch (RoborockSwitchBase:is_on,enable(),disable()), backed by a newCollisionAvoidStatusRoborockBasemodel.CollisionAvoidanceModeTrait(device.v1_properties.collision_avoidance_mode): for two-level devices. It decodesstatusinto the newCollisionAvoidanceModeRoborockEnum(1 = high_coverage,2 = less_collision, any other value →unknown, with the raw value kept instatus; the labels are inferred, see Testing) and sets it withset_collision_avoidance_mode(mode). PassingunknownraisesRoborockUnsupportedFeatureand sends no command.Setters update the cached value optimistically after the
SETcall, the same wayChildLockTraitandMopDryerTraitdo.Gating
collision_avoidanceis created whenis_avoid_collision_supported(robot new-features bit134217728) is set andis_two_gears_no_collision_supportedis not set.collision_avoidance_modeis created whenis_two_gears_no_collision_supported(new feature string bitTWO_GEARS_NO_COLLISION) is set.Two-level devices get only the mode trait. They also report the on/off bit, and exposing both traits would give two controls over the same value. Because of the extra condition, the switch is created in
discover_features()and skipped in the generic optional-trait loop, the same wayObstaclePhotoTraitis.Testing
tests/devices/traits/v1/test_collision_avoidance.py, which uses the shareddevice/mock_rpc_channel/discover_features_fixturefixtures withtrait_home_dataoverridden through indirect parametrization. It covers:unknownSETpayloads sent byenable()/disable()/set_collision_avoidance_mode()unknownwithout sending a commanduv run pytest -n auto: 2834 passed, 46 xfailed.ruff check,ruff format --checkandmypy roborock testsare clean, apart from the existingtests/map/test_b01_q10_render.py:502error that is already onmain.This hasn't been tested on hardware. The feature flags and command docs establish only that two-level devices exist and that
statuscarries the value; nothing in the repo maps1/2to named levels. Thehigh_coverage/less_collisionlabels are inferred, and unrecognised values decode tounknownwith the raw value kept instatus.Related open PRs
#1036 and #1045 also edit the "skip traits created above" line in
PropertiesApi.discover_features()(and #1045 also edits the module import lists). Whichever lands second has a one-line conflict, resolved by adding both trait classes to the tuple.🤖 Generated with Claude Code