feat: support Home Assistant clean_area (room cleaning) for vacuum#1743
Open
eduardobittencourt wants to merge 1 commit into
Open
feat: support Home Assistant clean_area (room cleaning) for vacuum#1743eduardobittencourt wants to merge 1 commit into
eduardobittencourt wants to merge 1 commit into
Conversation
Implement Home Assistant core's CLEAN_AREA vacuum feature so users can
clean specific rooms by selecting Home Assistant areas
(vacuum.clean_area). HA core handles the area<->segment mapping UI and
storage; the integration only needs to expose the device's rooms and
trigger a room sweep.
- vacuum.py:
- Capture the standard MIoT 'room-information' property and the
'start-vacuum-room-sweep' action; enable
VacuumEntityFeature.CLEAN_AREA when both are present and the running
HA core supports the feature (guarded import so older cores keep
working unchanged).
- async_get_segments(): parse 'room-information' into Segment(id, name).
- async_clean_segments(): send the selected room ids to the device via
the room-sweep action. 'vacuum-room-ids' is a JSON array string
(e.g. "[3, 10]"), consistent with the app_segment_clean payload in
XiaoMi#1702.
- specv2entity.py: route 'room-information' and 'start-vacuum-room-sweep'
into the vacuum entity (optional, so models without them are
unaffected).
Tested on xiaomi.vacuum.d102gl: mapping Home Assistant areas to rooms and
calling vacuum.clean_area cleans the selected rooms (single and multiple).
eduardobittencourt
marked this pull request as ready for review
June 26, 2026 18:27
|
@SusanPhevos this is a long waited feature to vacuum robots. This PR gonna be a quality of life update for real. |
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
Adds support for Home Assistant core's native
vacuum.clean_areaservice (theCLEAN_AREAfeature, available in recent HA core). Users can clean specific rooms by selecting Home Assistant areas; HA maps those areas to the vacuum's rooms (segments) and the integration tells the robot to clean them.This complements
send_command/app_segment_clean(e.g. #1702): it wires room cleaning into HA's first-class areas UI instead of requiring raw room ids in automations.How it works
HA core does the heavy lifting (the area↔segment mapping dialog + storage, and the
vacuum.clean_areaservice). An integration only needs to:VacuumEntityFeature.CLEAN_AREA,async_get_segments()→ the device's rooms,async_clean_segments(segment_ids)→ start a room sweep.This PR maps those onto the standard MIoT spec:
async_get_segments()reads theroom-informationproperty ({"rooms":[{"id","name"}]}) →Segment(id, name).async_clean_segments()calls thestart-vacuum-room-sweepaction withvacuum-room-idsas a JSON array string (e.g."[3, 10]").Everything is capability-gated and version-guarded:
CLEAN_AREAis enabled only when the device exposes bothroom-informationandstart-vacuum-room-sweep, so models without room cleaning are unaffected.Segment/CLEAN_AREAare imported behindtry/except+hasattr, so older HA core keeps working unchanged.Changes
vacuum.py: capture the room property/action, enableCLEAN_AREA, addasync_get_segments/async_clean_segments.miot/specs/specv2entity.py: routeroom-informationandstart-vacuum-room-sweepinto the vacuum entity (as optional).Test plan
Tested on
xiaomi.vacuum.d102gl(HA core 2026.6):vacuum.clean_arealists the vacuum (CLEAN_AREA feature present).async_get_segments)."[3, 10]".pylintclean on the changed lines (no new warnings).Notes
vacuum-room-idsstring is firmware-defined (the spec only types it asstr). The JSON array form works on the d102gl and matches theapp_segment_cleanpayload in feat: add complete support of S40 pro vacuum #1702; confirmation on other models is welcome.start-zone-sweep) the same way.