feat: Add native Home Assistant clean segment support#456
feat: Add native Home Assistant clean segment support#456patrick-morrison wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Home Assistant “clean by area / segments” support to the RoboVac vacuum entity by exposing user-configured room segments and mapping Home Assistant’s segment-clean requests back to the existing roomClean command.
Changes:
- Add parsing/storage for per-vacuum room segments (configured as
id:name) and a map ID. - Expose segments via
async_get_segments, implementasync_clean_segments, and enableVacuumEntityFeature.CLEAN_AREAwhen configured. - Extend the options flow + UI strings to configure
room_segment_map_idandroom_segments.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| custom_components/robovac/vacuum.py | Adds segment data model/parsing, HA segment APIs, and CLEAN_AREA feature gating; maps HA segment cleaning to roomClean. |
| custom_components/robovac/config_flow.py | Adds options-flow fields to configure map ID + segment definitions per vacuum. |
| custom_components/robovac/const.py | Introduces constants for the new options keys. |
| custom_components/robovac/strings.json | Adds labels/descriptions for the new options fields. |
Comments suppressed due to low confidence (1)
custom_components/robovac/vacuum.py:35
SegmentandVacuumEntityFeature.CLEAN_AREAare imported/used unconditionally. Sincemanifest.jsondoesn’t declare a minimum Home Assistant version, this will cause the integration to fail to load on HA versions that don’t yet provide these APIs. Consider guarding the import/feature enablement (e.g., try/except + graceful fallback) or explicitly declaring a minimum supported HA version in the manifest.
from homeassistant.components.vacuum import (
Segment,
StateVacuumEntity,
VacuumActivity,
VacuumEntityFeature,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "roomClean", | ||
| { | ||
| "room_ids": room_ids, | ||
| "map_id": self._room_segment_map.map_id, |
| "data": { | ||
| "autodiscovery": "Enable autodiscovery", | ||
| "ip_address": "IP Address" | ||
| "ip_address": "IP Address", | ||
| "room_segment_map_id": "Room segment map ID", | ||
| "room_segments": "Room segments" | ||
| }, | ||
| "data_description": { | ||
| "autodiscovery": "Automatically find the vacuum on the network.", | ||
| "ip_address": "The static IP address of your vacuum on your local network (optional if autodiscovery is enabled)." | ||
| "ip_address": "The static IP address of your vacuum on your local network (optional if autodiscovery is enabled).", | ||
| "room_segment_map_id": "The map ID used when cleaning configured room segments.", | ||
| "room_segments": "Comma-separated room segments in id:name format, for example 1:Kitchen,2:Living Room." | ||
| }, |
| def _parse_room_segments(raw_segments: str | None) -> tuple[RoomSegment, ...]: | ||
| """Parse configured room segments from 'id:name' comma-separated text.""" | ||
| if not raw_segments: | ||
| return () | ||
|
|
||
| segments: list[RoomSegment] = [] | ||
| for raw_segment in raw_segments.split(","): | ||
| segment = raw_segment.strip() | ||
| if not segment: | ||
| continue | ||
| raw_id, separator, name = segment.partition(":") | ||
| if not separator: | ||
| _LOGGER.warning("Ignoring room segment without ':' separator: %s", segment) | ||
| continue | ||
| try: | ||
| segment_id = int(raw_id.strip()) | ||
| except ValueError: | ||
| _LOGGER.warning("Ignoring room segment with invalid id: %s", segment) | ||
| continue | ||
| name = name.strip() | ||
| if not name: | ||
| _LOGGER.warning("Ignoring room segment without name: %s", segment) | ||
| continue | ||
| segments.append(RoomSegment(segment_id, name)) | ||
|
|
||
| return tuple(segments) |
|
Thanks, looks great. Small, sensible note from copilot there. If you could address that I'll get it merged asap |
|
Addressed in e6e08b2: added the missing translation keys, added focused segment/options tests, and propagated |
Summary
Adds Home Assistant native clean segment support for RoboVac room cleaning:
async_get_segmentsVacuumEntityFeature.CLEAN_AREAwhen segments are configuredroomCleancommandid:namesegment definitionsThis is aimed at Home Assistant 2026.5's new Clean by area vacuum dialog.
Notes
This does not hardcode any room IDs or device-specific maps. Users configure the map ID and segment list for each vacuum.
For models where
roomCleanalready works, this should plug into the native Home Assistant UI directly. L60/protobuf models still need the lower-level roomClean payload fix from #423.Validation
python3 -m py_compile custom_components/robovac/vacuum.py custom_components/robovac/config_flow.py