Skip to content

feat: Add native Home Assistant clean segment support#456

Open
patrick-morrison wants to merge 3 commits into
damacus:mainfrom
patrick-morrison:codex/native-clean-segments
Open

feat: Add native Home Assistant clean segment support#456
patrick-morrison wants to merge 3 commits into
damacus:mainfrom
patrick-morrison:codex/native-clean-segments

Conversation

@patrick-morrison
Copy link
Copy Markdown

Summary

Adds Home Assistant native clean segment support for RoboVac room cleaning:

  • exposes configured room segments through async_get_segments
  • enables VacuumEntityFeature.CLEAN_AREA when segments are configured
  • maps Home Assistant segment cleaning back to the existing roomClean command
  • adds options-flow fields for room segment map ID and id:name segment definitions

This 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 roomClean already 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

@patrick-morrison patrick-morrison marked this pull request as ready for review May 9, 2026 14:27
Copilot AI review requested due to automatic review settings May 9, 2026 14:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, implement async_clean_segments, and enable VacuumEntityFeature.CLEAN_AREA when configured.
  • Extend the options flow + UI strings to configure room_segment_map_id and room_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

  • Segment and VacuumEntityFeature.CLEAN_AREA are imported/used unconditionally. Since manifest.json doesn’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,
Comment on lines 39 to 50
"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."
},
Comment on lines +105 to +130
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)
@damacus damacus changed the title Add native Home Assistant clean segment support feat: Add native Home Assistant clean segment support May 9, 2026
@damacus
Copy link
Copy Markdown
Owner

damacus commented May 9, 2026

Thanks, looks great. Small, sensible note from copilot there. If you could address that I'll get it merged asap

@patrick-morrison
Copy link
Copy Markdown
Author

Addressed in e6e08b2: added the missing translation keys, added focused segment/options tests, and propagated map_id through the existing roomClean payload when configured.

@damacus damacus enabled auto-merge (squash) May 12, 2026 05:31
@damacus damacus disabled auto-merge May 12, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants