feat: add MopDryerTrait for controlling the dock mop dryer - #952
Open
dschuld wants to merge 2 commits into
Open
Conversation
Adds a switch trait for starting and stopping a mop drying cycle via APP_SET_DRYER_STATUS, gated on the dock being able to dry. The dryer has no dedicated query command: whether a cycle is running is reported as dry_status on the device status. The trait therefore holds the status trait, reads is_on from it, and refreshes through it, applying the commanded value optimistically like the other switch traits. Named MopDryerTrait rather than DryerTrait to stay clear of the Zeo washer/dryer appliance support, which has its own dryer concepts.
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.
Summary
A switch trait for starting and stopping a mop drying cycle on docks that support
drying, via
APP_SET_DRYER_STATUS.dry_statusis already readable. It was annotated with dps metadata in #740 and isconsumed by Home Assistant through
is_field_supported(StatusV2, StatusField.DRY_STATUS). But there is no trait behind the write side, so callers have to fall back to a raw command.The trait is created in the special-case block in
discover_features()alongsideWashTowelModeTraitandObstaclePhotoTrait, since it takes a constructor argument.It is gated on
dock_features.is_dryable.Background
#262 asked for this in Dec 2024 and was closed by the reporter with:
APP_SET_DRYER_SETTINGconfigures the dry duration;APP_SET_DRYER_STATUSstarts andstops the cycle. That finding never made it into the library. I've confirmed the
command works against my own dock.
Open Issues / Design Choices
1. Where the state comes from. Unlike the other switch traits, the dryer has no query
command of its own. If a cycle is running is reported as
dry_statusonStatusV2.So this trait holds the status trait, reads
is_onfrom it, and overridesrefresh()todelegate, leaving
V1TraitMixin'scommand/converterunused.That is a deliberate deviation from the pattern documented in the module docstring
("subclass
V1TraitMixinand aRoborockBasedataclass… you must define acommandclass variable"). I would like to point this out here rather than have it found in review.
The alternative is a self-contained trait backed by
APP_GET_DRYER_SETTINGwith a newDryerSettingdataclass, which would also expose the dry-duration setting. I didn't gothat way because I have no sample of that response and didn't want to guess at the wire
format. I am happy to capture it from my dock and rework this if this approach is preferred.
Testing
50 new tests in
tests/devices/traits/v1/test_mop_dryer.py:is_dryableis true, and absent for all whereit is false (parametrized over the full
RoborockDockTypeCodeenum)is_onmapping fordry_statusofNone/0/1enable()/disable()sendAPP_SET_DRYER_STATUSwith the right params and apply theoptimistic update
refresh()delegates to the status trait100% line and branch coverage on the new module.
AI assistance disclosure
This contribution was prepared with Claude Code assistance. I reviewed the submitted changes and test results and take responsibility for the contribution.
Closes #905