Skip to content

Add carpet zone detection and rendering support.#40

Merged
sca075 merged 16 commits intomainfrom
dev_main
Jan 11, 2026
Merged

Add carpet zone detection and rendering support.#40
sca075 merged 16 commits intomainfrom
dev_main

Conversation

@sca075
Copy link
Owner

@sca075 sca075 commented Jan 11, 2026

This PR adds full support for carpet zone detection and rendering in the Valetudo map parser, and fixes floor rendering to use the correct background color.

✨ What's New

  1. Carpet Zone Support
    Added CARPET to DrawableElement enum (value: 12, z-index: 15)
    Carpets are rendered above floor but below walls
    Carpets are detected from Valetudo JSON as PolygonMapEntity with type="carpet"
  2. Configurable Carpet Appearance
    color_carpet: RGB color for carpet zones (default: [67, 103, 125] - 50% of room_0 color)
    alpha_carpet: Alpha transparency (default: 255.0 - full opacity)
    disable_carpets: Boolean flag to hide/show carpets (default: false)
  3. New Type Definitions
    Added PolygonMeta TypedDict for polygon metadata
    Added PolygonMapEntity TypedDict for polygon-based map entities
    Updated Entity union type to include PolygonMapEntity

Summary by CodeRabbit

  • New Features

    • Carpet area visualization with its own color/opacity and optional per-device enable/disable
    • Carpet-aware zone drawing integrated into map rendering
    • Polygon-based map entities for richer, more accurate shapes
  • Enhancements

    • Trim/crop data now tracks floor context per floor
  • Chores

    • Version bumped to 0.1.16
    • Package dependency updated

✏️ Tip: You can customize this high-level summary in your review settings.

Signed-off-by: Sandro Cantarella <sandro@Sandros-Mac-mini.fritz.box>
Signed-off-by: Sandro Cantarella <sandro@79f3d049-9006-400d-9954-2e5dcd250fa9.fritz.box>
Signed-off-by: Sandro Cantarella <sandro@Sandros-Mac-mini.fritz.box>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
…it bump version in pyproject.toml added to __init__.py Trims and Floor Data

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
…ses old key trims_data

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
- Add CARPET drawable element with configurable color and alpha
- Implement carpet zone parsing from Valetudo JSON (PolygonMapEntity)
- Add carpet rendering with customizable color (default: 50% of room_0)
- Support disable_carpets flag to toggle carpet visibility
- Fix COLORS list order to match base_color_keys mapping
- Fix floor rendering to use correct MAP_BACKGROUND color
- Add carpet color configuration to device_info

Fixes color index mismatch that affected carpet and floor color updates

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
@sca075 sca075 self-assigned this Jan 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

📝 Walkthrough

Walkthrough

Adds carpet as a drawable map element (constants, enum, defaults, drawing), threads floor info into trim data, adds polygon entity support, derives compressedPixels when missing, and bumps package/version and dependency.

Changes

Cohort / File(s) Summary
Color constants & defaults
SCR/valetudo_map_parser/const.py, SCR/valetudo_map_parser/config/colors.py
Add COLOR_CARPET/ALPHA_CARPET, color_carpet RGBA, register SupportedColor.CARPET, and include carpet in default color/alpha maps and color key arrays.
Drawable element & mappings
SCR/valetudo_map_parser/config/drawable_elements.py
Add DrawableElement.CARPET; map to SupportedColor.CARPET, set z-index (15), initialize color/alpha for carpets, and support disable_carpets device-info flag.
Trim floor tracking
SCR/valetudo_map_parser/config/types.py, SCR/valetudo_map_parser/config/utils.py
Add floor: str to TrimCropData, include in to_dict/from_dict, extend from_list signature to accept floor, and pass self.shared.current_floor at call sites.
Carpet drawing pipeline
SCR/valetudo_map_parser/hypfer_draw.py, SCR/valetudo_map_parser/hypfer_handler.py
Extend async_draw_zones with optional color_carpet; integrate carpet drawing gated by enable flags and provided color; handler forwards colors.get("carpet").
Map entity types & layer handling
SCR/valetudo_map_parser/map_data.py
Add PolygonMeta and PolygonMapEntity TypedDicts; expand Entity union to include polygons; derive compressedPixels from pixels when missing for layer grouping.
Misc / maintenance
SCR/valetudo_map_parser/config/shared.py, pyproject.toml
Remove unused CONF_SNAPSHOTS_ENABLE import; bump package version to 0.1.16 and mvcrender dependency to ==0.0.7.

Sequence Diagram

sequenceDiagram
    participant Handler as HypferHandler
    participant Draw as ImageDraw
    participant Rooms as RoomStore
    participant Canvas as NumpyArray

    Handler->>Draw: async_draw_zones(m_json, np_array, color_zone_clean, color_no_go, color_carpet)
    Draw->>Draw: identify carpet_zones from m_json
    alt carpet_zones present and color_carpet provided and carpets enabled
        loop for each carpet polygon/segment
            Draw->>Rooms: lookup room for polygon segment
            Rooms-->>Draw: room id / room color
            Draw->>Draw: compute carpet color (50% room brightness, alpha 255)
            Draw->>Canvas: rasterize carpet polygon onto array
        end
    end
    Draw-->>Handler: np_array with carpets rendered
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

Poem

🐰 Soft paws on patches, carpet hues in sight,

Floors now traced and polygons take flight,
Colors stitched where rooms reside,
Tiny rabbit hums with pride,
Map hops brighter through the night.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add carpet zone detection and rendering support' accurately and directly summarizes the main changes introduced in the PR, which adds carpet zone detection and rendering functionality throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
SCR/valetudo_map_parser/config/types.py (1)

84-92: from_dict will raise KeyError for existing data without floor key.

Using data["floor"] directly throws a KeyError if the key is missing from legacy serialized data. Consider using data.get("floor", "floor_0") for backward compatibility with existing configurations.

🐛 Proposed fix for backward compatibility
     @staticmethod
     def from_dict(data: dict):
         """Create dataclass from dictionary."""
         return TrimCropData(
-            floor=data["floor"],
+            floor=data.get("floor", "floor_0"),
             trim_left=data["trim_left"],
             trim_up=data["trim_up"],
             trim_right=data["trim_right"],
             trim_down=data["trim_down"],
         )
SCR/valetudo_map_parser/config/drawable_elements.py (1)

207-219: Critical: Missing CARPET in element_color_mapping breaks device_info color configuration.

The element_color_mapping in update_from_device_info is missing the DrawableElement.CARPET entry, while the identical mapping in _set_default_properties (lines 86-99) includes it. This means user-provided color_carpet and alpha_carpet from device_info will be ignored, breaking the feature described in the PR objectives.

Additionally, this mapping is duplicated across two methods, violating DRY principles and creating maintenance risks (as demonstrated by this bug).

🐛 Proposed fix: Add CARPET to mapping and eliminate duplication

Fix 1: Add the missing CARPET entry

         element_color_mapping = {
             DrawableElement.FLOOR: SupportedColor.MAP_BACKGROUND,
             DrawableElement.WALL: SupportedColor.WALLS,
             DrawableElement.ROBOT: SupportedColor.ROBOT,
             DrawableElement.CHARGER: SupportedColor.CHARGER,
             DrawableElement.VIRTUAL_WALL: SupportedColor.NO_GO,
             DrawableElement.RESTRICTED_AREA: SupportedColor.NO_GO,
             DrawableElement.PATH: SupportedColor.PATH,
             DrawableElement.PREDICTED_PATH: SupportedColor.PREDICTED_PATH,
             DrawableElement.GO_TO_TARGET: SupportedColor.GO_TO,
             DrawableElement.NO_MOP_AREA: SupportedColor.NO_GO,
             DrawableElement.OBSTACLE: SupportedColor.NO_GO,
+            DrawableElement.CARPET: SupportedColor.CARPET,
         }

Fix 2 (Recommended): Extract to class constant to eliminate duplication

Add a class-level constant after line 18:

# Map DrawableElement to SupportedColor for non-room elements
_ELEMENT_COLOR_MAPPING = {
    DrawableElement.FLOOR: SupportedColor.MAP_BACKGROUND,
    DrawableElement.WALL: SupportedColor.WALLS,
    DrawableElement.ROBOT: SupportedColor.ROBOT,
    DrawableElement.CHARGER: SupportedColor.CHARGER,
    DrawableElement.VIRTUAL_WALL: SupportedColor.NO_GO,
    DrawableElement.RESTRICTED_AREA: SupportedColor.NO_GO,
    DrawableElement.PATH: SupportedColor.PATH,
    DrawableElement.PREDICTED_PATH: SupportedColor.PREDICTED_PATH,
    DrawableElement.GO_TO_TARGET: SupportedColor.GO_TO,
    DrawableElement.NO_MOP_AREA: SupportedColor.NO_GO,
    DrawableElement.OBSTACLE: SupportedColor.NO_GO,
    DrawableElement.CARPET: SupportedColor.CARPET,
}

Then replace both local definitions (lines 86-99 and 207-219) with references to this constant.

🧹 Nitpick comments (2)
SCR/valetudo_map_parser/map_data.py (1)

277-293: Edge case: odd-length pixels array silently drops the last element.

The conversion logic correctly handles the case where compressedPixels is missing by deriving it from pixels. However, if pixels has an odd length (malformed data), the last element is silently dropped. Consider logging a warning for debugging purposes.

🔧 Optional: Add warning for malformed data
                         pixels = json_obj.get("pixels", [])
                         if pixels:
+                            if len(pixels) % 2 != 0:
+                                # Log warning for malformed pixel data
+                                pass  # or use appropriate logger
                             # Convert pairs to triplets by adding count=1 for each pixel
                             compressed_pixels = []
                             for i in range(0, len(pixels), 2):
SCR/valetudo_map_parser/hypfer_draw.py (1)

315-364: Dead code: _draw_carpets method is never called.

This method appears to be leftover development code. The actual carpet drawing is handled at lines 309-311 using self.img_h.draw.zones directly. Additionally, the import from .config.room_store import RoomStore on line 319 is incorrect—RoomStore is already imported from .config.types at line 12.

Consider removing this unused method to avoid confusion and maintenance burden.

♻️ Remove dead code
-    async def _draw_carpets(
-        self, np_array: NumpyArray, carpet_zones: list
-    ) -> NumpyArray:
-        """Draw carpet zones with 50% of room color and alpha 255."""
-        from .config.room_store import RoomStore
-
-        # Get room store to map segment IDs to room indices
-        room_store = RoomStore(self.file_name)
-        room_keys = list(room_store.get_rooms().keys())
-
-        for carpet in carpet_zones:
-            try:
-                # Get the segment ID from carpet metadata
-                segment_id = carpet.get("metaData", {}).get("id")
-                if not segment_id:
-                    continue
-
-                # Find the room index for this segment ID
-                if segment_id in room_keys:
-                    room_index = room_keys.index(segment_id)
-                else:
-                    # Default to room 0 if segment ID not found
-                    room_index = 0
-
-                # Get the room color
-                if room_index < len(self.img_h.shared.rooms_colors):
-                    room_color = self.img_h.shared.rooms_colors[room_index]
-                else:
-                    room_color = self.img_h.shared.rooms_colors[0]
-
-                # Calculate carpet color: 50% of room color with alpha 255
-                carpet_color = (
-                    room_color[0] // 2,
-                    room_color[1] // 2,
-                    room_color[2] // 2,
-                    255,  # Full opacity
-                )
-
-                # Draw the carpet zone
-                np_array = await self.img_h.draw.zones(
-                    np_array, [carpet], carpet_color
-                )
-
-            except (KeyError, TypeError, IndexError) as e:
-                _LOGGER.warning(
-                    "%s: Error drawing carpet: %s", self.file_name, str(e)
-                )
-                continue
-
-        return np_array
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4969760 and 3b9d5b2.

📒 Files selected for processing (10)
  • SCR/valetudo_map_parser/config/colors.py
  • SCR/valetudo_map_parser/config/drawable_elements.py
  • SCR/valetudo_map_parser/config/shared.py
  • SCR/valetudo_map_parser/config/types.py
  • SCR/valetudo_map_parser/config/utils.py
  • SCR/valetudo_map_parser/const.py
  • SCR/valetudo_map_parser/hypfer_draw.py
  • SCR/valetudo_map_parser/hypfer_handler.py
  • SCR/valetudo_map_parser/map_data.py
  • pyproject.toml
💤 Files with no reviewable changes (1)
  • SCR/valetudo_map_parser/config/shared.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-12-19T10:03:55.490Z
Learnt from: sca075
Repo: sca075/Python-package-valetudo-map-parser PR: 29
File: SCR/valetudo_map_parser/hypfer_draw.py:438-462
Timestamp: 2025-12-19T10:03:55.490Z
Learning: In SCR/valetudo_map_parser/hypfer_draw.py, the `_check_room_with_corners` method correctly sets `self.img_h.robot_in_room` before validation. This state mutation pattern during room iteration is intentional and works correctly with the coordinate system used by the Hypfer handler, similar to the Rand256 handler pattern.

Applied to files:

  • SCR/valetudo_map_parser/hypfer_draw.py
  • SCR/valetudo_map_parser/hypfer_handler.py
📚 Learning: 2025-10-11T14:02:20.278Z
Learnt from: sca075
Repo: sca075/Python-package-valetudo-map-parser PR: 21
File: SCR/valetudo_map_parser/config/drawable.py:56-56
Timestamp: 2025-10-11T14:02:20.278Z
Learning: In the valetudo-map-parser codebase, the Color type definition (`Union[Tuple[int, int, int], Tuple[int, int, int, int]]`) allows both RGB and RGBA to accommodate Home Assistant's RGB selector during configuration (which doesn't accept alpha channels). However, alpha is added during config processing, so by the time colors reach the drawing/processing code in files like drawable.py, they are always RGBA (4-tuple). Therefore, direct access to color[3] is safe in all drawing and processing code, and guards are not needed.

Applied to files:

  • SCR/valetudo_map_parser/const.py
  • SCR/valetudo_map_parser/config/colors.py
🧬 Code graph analysis (2)
SCR/valetudo_map_parser/config/utils.py (1)
SCR/valetudo_map_parser/config/types.py (3)
  • TrimsData (293-347)
  • from_list (99-107)
  • from_list (328-338)
SCR/valetudo_map_parser/config/drawable_elements.py (1)
SCR/valetudo_map_parser/config/colors.py (1)
  • SupportedColor (144-163)
🔇 Additional comments (19)
pyproject.toml (2)

3-3: LGTM: Version bump is appropriate.

The patch version increment from 0.1.14 to 0.1.15 is reasonable for the carpet zone feature addition in a pre-1.0 release.


21-21: mvcrender version 0.0.7 is available on PyPI with no known security vulnerabilities.

The dependency update to ==0.0.7 is valid and verified.

SCR/valetudo_map_parser/hypfer_handler.py (2)

133-133: LGTM!

The comment clarification accurately documents the existing behavior that floor layers are always drawn when present, improving code readability.


232-235: LGTM!

The integration of carpet color into the zone drawing pipeline is clean. Using colors.get("carpet") safely returns None when the color isn't configured, and the callee (async_draw_zones) handles this gracefully with its default parameter color_carpet=None.

SCR/valetudo_map_parser/map_data.py (1)

120-135: LGTM!

The new PolygonMeta and PolygonMapEntity TypedDicts follow the established patterns for entity types, and the Entity union is properly extended to include the new polygon type.

SCR/valetudo_map_parser/config/types.py (2)

66-67: LGTM!

The new floor field is properly added to the TrimCropData dataclass.


98-107: LGTM!

The from_list method correctly accepts an optional floor parameter with a sensible default value of "floor_0".

SCR/valetudo_map_parser/const.py (3)

36-47: LGTM!

The COLORS list is correctly extended with "carpet" and "text" entries. The ordering aligns with the base_color_keys in colors.py, ensuring correct index-based color mapping throughout the codebase.


88-88: LGTM!

The trims_data default now includes the floor field with a sensible default value of "floor_0", aligning with the TrimCropData dataclass changes.


97-97: LGTM!

The carpet color and alpha constants are properly defined with consistent naming conventions. The default carpet color [67, 103, 125] (a muted blue-gray) provides reasonable visual distinction from floor/room colors.

Also applies to: 107-107, 236-236, 266-266

SCR/valetudo_map_parser/hypfer_draw.py (2)

105-122: LGTM!

The floor layer handling is improved:

  1. Floor layers consistently use rooms_colors[0] for visual uniformity across vacuum models
  2. room_id is only incremented for segment layers, preventing index drift when floor layers are processed

This ensures correct room color assignment regardless of layer ordering in the JSON data.


262-313: LGTM!

The carpet zone drawing integration is clean:

  • The color_carpet parameter with None default maintains backward compatibility
  • Carpet rendering is properly gated by three conditions: zones exist, color is provided, and the CARPET element is enabled
  • Follows the established pattern for zone drawing
SCR/valetudo_map_parser/config/colors.py (3)

13-13: LGTM!

The carpet color constants are properly imported and defined. The color_carpet RGBA value (67, 103, 125, 255) correctly combines the RGB from const.py with full opacity.

Also applies to: 39-39, 69-69


155-155: LGTM!

The SupportedColor.CARPET enum member and its corresponding RGB entry in COLORS_RGB are correctly added. The comment accurately notes that (67, 103, 125) represents 50% of the default room_0 color (135, 206, 250).

Also applies to: 178-178


302-313: LGTM!

The COLOR_CARPET entry in base_color_keys is positioned correctly at index 6, matching the position of "carpet" in the COLORS list in const.py. This ensures consistent color mapping across the codebase.

SCR/valetudo_map_parser/config/utils.py (1)

276-280: The code change is correct and safe. The self.shared.current_floor attribute is always initialized to "floor_0" when the shared data object is created (line 124 in shared.py), and it's guaranteed to be set in the from_dict method regardless of whether device info contains floors data or falls back to defaults (lines 321, 326). No AttributeError risk exists.

SCR/valetudo_map_parser/config/drawable_elements.py (3)

36-36: LGTM!

The CARPET enum value is correctly defined and follows the sequential numbering pattern.


86-115: LGTM!

The CARPET element is correctly integrated into the default properties:

  • Mapped to SupportedColor.CARPET for color configuration
  • Assigned z-index 15, placing it above floor and below walls as intended

263-276: LGTM!

The disable_carpets flag is correctly mapped to DrawableElement.CARPET, following the same pattern as other element disable flags.

@sca075 sca075 added bug Something isn't working enhancement New feature or request labels Jan 11, 2026
@sca075 sca075 linked an issue Jan 11, 2026 that may be closed by this pull request
from_list

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Fixes carpet color/alpha from device_info not being applied due to
missing DrawableElement.CARPET entry in update_from_device_info().

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
SCR/valetudo_map_parser/config/drawable_elements.py (2)

101-115: Avoid ambiguous layering ties (CARPET and OBSTACLE both z=15).
If both are enabled, draw order will effectively depend on enum iteration order when z_index ties—verify this is the intended stacking (do you want obstacles above carpets?).

Possible tweak (make ordering explicit by breaking the tie)
 z_indices = {
@@
-    DrawableElement.CARPET: 15,  # Draw carpets above floor but below walls
-    DrawableElement.OBSTACLE: 15,
+    DrawableElement.CARPET: 15,  # Draw carpets above floor but below walls
+    DrawableElement.OBSTACLE: 16,  # Keep obstacles above carpets (if desired)
@@
 }

204-261: Device-info color/alpha update for CARPET is correctly hooked up; consider using .value for alpha keys.
Today alpha_key = f"alpha_{color_key}" relies on StrEnum formatting; alpha_{color_key.value} is clearer and avoids surprises if the enum implementation changes.

Proposed clarity-only change
-                alpha_key = f"alpha_{color_key}"
+                alpha_key = f"alpha_{color_key.value}"
                 alpha = device_info.get(alpha_key, 255.0)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bea98e and de0effa.

📒 Files selected for processing (1)
  • SCR/valetudo_map_parser/config/drawable_elements.py
🧰 Additional context used
🧬 Code graph analysis (1)
SCR/valetudo_map_parser/config/drawable_elements.py (1)
SCR/valetudo_map_parser/config/colors.py (1)
  • SupportedColor (144-163)
🔇 Additional comments (3)
SCR/valetudo_map_parser/config/drawable_elements.py (3)

85-100: Default mapping for CARPET looks correct.
Wiring DrawableElement.CARPETSupportedColor.CARPET ensures default color/opacity init runs for carpets as intended.


262-277: The key name disable_carpets (plural) is correct and consistent with the codebase. It follows the same pattern as other multi-element flags like disable_virtual_walls, disable_restricted_areas, and disable_obstacles, which all map to singular enum names. The enum DrawableElement.CARPET is properly defined and actively used throughout the codebase for color mapping and rendering checks.


21-37: No actionable issues identified. The CARPET enum addition is fully integrated with consistent color, alpha, z-index, and disable flag mappings. The implementation handles all integration points correctly.

…tial implementation attempt and is not needed since we're using the simpler approach of passing color_carpet directly from device_info to the zones() drawing method.

Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @SCR/valetudo_map_parser/hypfer_draw.py:
- Around line 302-311: The carpet zone drawing block may raise AttributeError by
calling self.img_h.drawing_config.is_enabled without ensuring drawing_config
exists; add the same defensive check pattern used elsewhere: verify
hasattr(self.img_h, "drawing_config") and that self.img_h.drawing_config is not
None before calling is_enabled(DrawableElement.CARPET), and only call
self.img_h.draw.zones(np_array, carpet_zones, color_carpet) when carpet_zones,
color_carpet and the defensive drawing_config check all pass.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de0effa and 644b81e.

📒 Files selected for processing (2)
  • SCR/valetudo_map_parser/hypfer_draw.py
  • pyproject.toml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-12-19T10:03:55.490Z
Learnt from: sca075
Repo: sca075/Python-package-valetudo-map-parser PR: 29
File: SCR/valetudo_map_parser/hypfer_draw.py:438-462
Timestamp: 2025-12-19T10:03:55.490Z
Learning: In SCR/valetudo_map_parser/hypfer_draw.py, the `_check_room_with_corners` method correctly sets `self.img_h.robot_in_room` before validation. This state mutation pattern during room iteration is intentional and works correctly with the coordinate system used by the Hypfer handler, similar to the Rand256 handler pattern.

Applied to files:

  • SCR/valetudo_map_parser/hypfer_draw.py
🧬 Code graph analysis (1)
SCR/valetudo_map_parser/hypfer_draw.py (3)
SCR/valetudo_map_parser/config/drawable_elements.py (2)
  • is_enabled (174-176)
  • DrawableElement (21-53)
SCR/valetudo_map_parser/config/drawable.py (1)
  • zones (315-395)
tests/refactored.py (1)
  • zones (429-448)
🔇 Additional comments (4)
pyproject.toml (2)

3-3: Verify the version skip from 0.1.14 to 0.1.16.

The version increment skips 0.1.15. While this can be intentional, please confirm whether version 0.1.15 was used elsewhere or if this skip is intentional.


21-21: The mvcrender version 0.0.7 is legitimate and available on PyPI.

Version 0.0.7 exists and is published by the mvcrender maintainer (sca075). The package is a well-maintained C extension library for image processing used by the Valetudo Map Parser project. No security vulnerabilities are reported, and the release includes proper wheel distributions for supported platforms. The dependency is safe to use.

SCR/valetudo_map_parser/hypfer_draw.py (2)

105-122: LGTM: Floor layer handling ensures consistent background color.

The logic correctly ensures floor layers always use rooms_colors[0] while segment layers retain the active room color behavior. The conditional room_id increment prevents room color cycling for floor layers, which is the intended behavior.


268-268: LGTM: Backward-compatible API extension.

The optional color_carpet parameter with a default value of None maintains backward compatibility while enabling carpet zone rendering.

@sca075 sca075 merged commit df0a685 into main Jan 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When the vacuum is mapping the "floor" no map is rendered.

1 participant