Conversation
…e code quality to 10/10 - Add dock_state attribute to track docking station operations (self_cleaning, emptying, etc.) - Refactor map_data.py to reduce complexity (extract helper methods) - Refactor drawable_elements.py to use dictionary-driven loops - Fix exception handling in hypfer_draw.py (use specific exceptions) - Remove commented-out code from hypfer_draw.py Quality improvements: - Pylint score: 10.00/10 (perfect score) - Fixed W0718: Replace broad Exception with specific exceptions - Fixed R0912: Reduce branches from 16→6 (map_data) and 14→10 (drawable_elements) - Fixed R1702: Reduce nested blocks from 7→3 (map_data) - All code formatted with ruff and isort Modified files: - SCR/valetudo_map_parser/const.py - SCR/valetudo_map_parser/__init__.py - SCR/valetudo_map_parser/config/shared.py - SCR/valetudo_map_parser/config/status_text/status_text.py - SCR/valetudo_map_parser/map_data.py - SCR/valetudo_map_parser/hypfer_draw.py - SCR/valetudo_map_parser/config/drawable_elements.py Tests: ✅ All passing (440.8ms image generation) fix: Convert float device_info values to integers (Pi4 compatibility) fix: Correct calibration points coordinate swap ## Pi4 Float to Integer Conversion On Raspberry Pi 4 and other systems, Home Assistant can pass device_info configuration values as floats (e.g., 255.0, 100.0) even when they should be integers. This caused "TypeError: 'float' object cannot be interpreted as an integer" when AutoCrop initialization accessed these values. Changes: - Convert offset values (offset_top, offset_down, offset_left, offset_right) to int - Convert size values (vacuum_status_size, mop_path_width) to int with error handling - Update TrimsData.from_dict(), from_json(), and from_list() to convert trim values to int - Update TrimCropData.from_dict() and from_list() to convert trim values to int Note: Color alpha values intentionally remain as floats in device_info and are converted to integers only when creating final RGBA tuples, so color handling is unaffected. ## Calibration Points Coordinate Swap Fix Fixed critical bug where X and Y coordinates were swapped in calibration points calculation. The crop_area format is [left, up, right, down], but get_vacuum_points() was incorrectly mapping crop_area[0] (left) to x and crop_area[1] (up) to y. Corrected mapping: - crop_area[1] (up) → x (was crop_area[0]) - crop_area[0] (left) → y (was crop_area[1]) Impact: - Robot position on map is now correctly placed - Touch-to-go coordinates work correctly - Room detection reports the correct room - Fixes issue where robot at x:3464, y:3262 was showing [3162, 3442] instead of [3442, 3162] ## Test Fixes - Fix typo in tests/test.py: trim_left 240.0 → 2400.0 ## Version - Bump version from 0.2.3 to 0.2.4b1 for beta testing in Home Assistant Files modified: - pyproject.toml - SCR/valetudo_map_parser/__init__.py - SCR/valetudo_map_parser/config/shared.py - SCR/valetudo_map_parser/config/types.py - SCR/valetudo_map_parser/config/utils.py - tests/test.py Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
- Fix active_list alignment in map_data.py: append 0 on conversion failure instead of skipping - Remove duplicate color_mop_move and alpha_mop_move keys in tests/test.py Ensures segment-to-active-zone index correspondence and eliminates dict key override issues. Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
… version 0.2.4b3 release 🐛 Critical Bug Fixes: - Fixed calibration points not updating when map rotation changes * Removed incorrect rotation reordering logic in get_vacuum_points() * Calibration data now recalculates on every image generation * Ensures coordinate mapping works correctly at all rotation angles - Fixed segment alignment bug in map_data.py - Fixed rotation change handling to prevent "Invalid crop region" errors * Added rotation tracking to FloorData class * Detects when saved rotation differs from current rotation * Automatically resets trims for recalculation when rotation changes * Prevents errors when user changes rotation with saved floor data ✨ Implementation Details: - Added rotation: int field to FloorData class - update_trims() now saves current image_rotate with trims - On reload, compares saved rotation with current rotation - If different, resets trims to defaults and lets auto-crop recalculate - Logs rotation changes for debugging ✨ Updates: - Version bumped to 0.2.4b3 - Updated mvcrender dependency to 0.1.0 https://github.com/sca075/mvcrender/releases/tag/v0.1.0 - Comprehensive documentation updates (README.md, CHANGELOG.md) - New test: test_reload_rotation_change.py ✅ Quality Gate: - Pylint: 10.00/10 - All checks passed - Tests: PASSED * test_autocrop_floor.py: Calibration points correctly change with rotation * test_reload_rotation_change.py: Rotation change detection working, trims reset and recalculated * test.py: Image generation 432.6ms avg 📝 Modified Files: - SCR/valetudo_map_parser/config/types.py (rotation field in FloorData) - SCR/valetudo_map_parser/config/utils.py (update_trims with rotation, calibration fixes) - SCR/valetudo_map_parser/config/shared.py (rotation change detection) - tests/test_reload_rotation_change.py (new test) - pyproject.toml (version bump, mvcrender 0.1.0) - README.md (version and features update) - CHANGELOG.md (comprehensive v0.2.4 release notes with rotation change handling) Ready for Home Assistant testing. Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
…rop_area mapping
CRITICAL FIX: Fixed TrimsData.from_list() mapping where crop_area indices
were completely backwards, causing impossible trim values (trim_left > trim_right)
and broken calibration points.
The crop_area format is [left, up, right, down], so the correct mapping is:
- crop_area[0] → trim_left (was incorrectly mapped to trim_up)
- crop_area[1] → trim_up (was incorrectly mapped to trim_left)
- crop_area[2] → trim_right (was incorrectly mapped to trim_down)
- crop_area[3] → trim_down (was incorrectly mapped to trim_right)
This bug caused:
- Calibration points to be completely wrong
- Click-to-go to send vacuum to wrong locations
- Room boundaries to be incorrect
- All coordinate mapping features to fail
Test verification (test_autocrop_floor.py):
✅ All trim values now satisfy: trim_left < trim_right and trim_up < trim_down
✅ Calibration points correctly track vacuum position across rotations
✅ Robot position consistent: {'x': 3231, 'y': 3275, 'angle': 90.0}
Modified:
- SCR/valetudo_map_parser/config/types.py (lines 333-345)
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
…rop_area mapping
CRITICAL FIX: Fixed TrimsData.from_list() mapping where crop_area indices
were completely backwards, causing impossible trim values (trim_left > trim_right)
and broken calibration points.
The crop_area format is [left, up, right, down], so the correct mapping is:
- crop_area[0] → trim_left (was incorrectly mapped to trim_up)
- crop_area[1] → trim_up (was incorrectly mapped to trim_left)
- crop_area[2] → trim_right (was incorrectly mapped to trim_down)
- crop_area[3] → trim_down (was incorrectly mapped to trim_right)
This bug caused:
- Calibration points to be completely wrong
- Click-to-go to send vacuum to wrong locations
- Room boundaries to be incorrect
- All coordinate mapping features to fail
Test verification (test_autocrop_floor.py):
✅ All trim values now satisfy: trim_left < trim_right and trim_up < trim_down
✅ Calibration points correctly track vacuum position across rotations
✅ Robot position consistent: {'x': 3231, 'y': 3275, 'angle': 90.0}
Modified:
- SCR/valetudo_map_parser/config/types.py (lines 333-345)
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
CRITICAL FIX: Fixed calibration coordinate system mismatch between NumPy (y,x) and Home Assistant (x,y). NumPy uses (row, column) indexing while Home Assistant expects standard Cartesian (x, y) coordinates. Changes: - Swapped X and Y coordinates in get_vacuum_points() to compensate for the coordinate system difference - Fixed TrimsData.from_list() to correctly map crop_area indices - Added detailed logging for calibration calculation debugging The Problem: - mvcrender outputs crop_area in NumPy (y, x) format - Home Assistant expects (x, y) Cartesian coordinates - Without the swap, calibration points had X and Y reversed - This caused click-to-go to send vacuum to wrong locations The Solution: In get_vacuum_points(), we now swap coordinates: x = crop_area[1] + offset_y (use 'up' for x) y = crop_area[0] + offset_x (use 'left' for y) Impact: - Calibration points now correctly map image pixels to vacuum coordinates - Click-to-go functionality works correctly - All rotation angles (0°, 90°, 180°, 270°) produce correct calibration Test Results: ✅ test_autocrop_floor.py passes with correct calibration for all rotations ✅ Coordinates now match Home Assistant's expected format Modified: - SCR/valetudo_map_parser/config/utils.py (get_vacuum_points) - SCR/valetudo_map_parser/config/types.py (TrimsData.from_list) - SCR/valetudo_map_parser/hypfer_handler.py (added logging) Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
…e code quality to 10/10 - Add dock_state attribute to track docking station operations (self_cleaning, emptying, etc.) - Refactor map_data.py to reduce complexity (extract helper methods) - Refactor drawable_elements.py to use dictionary-driven loops - Fix exception handling in hypfer_draw.py (use specific exceptions) - Remove commented-out code from hypfer_draw.py Quality improvements: - Pylint score: 10.00/10 (perfect score) - Fixed W0718: Replace broad Exception with specific exceptions - Fixed R0912: Reduce branches from 16→6 (map_data) and 14→10 (drawable_elements) - Fixed R1702: Reduce nested blocks from 7→3 (map_data) - All code formatted with ruff and isort Modified files: - SCR/valetudo_map_parser/const.py - SCR/valetudo_map_parser/__init__.py - SCR/valetudo_map_parser/config/shared.py - SCR/valetudo_map_parser/config/status_text/status_text.py - SCR/valetudo_map_parser/map_data.py - SCR/valetudo_map_parser/hypfer_draw.py - SCR/valetudo_map_parser/config/drawable_elements.py Tests: ✅ All passing (440.8ms image generation) fix: Convert float device_info values to integers (Pi4 compatibility) fix: Correct calibration points coordinate swap ## Pi4 Float to Integer Conversion On Raspberry Pi 4 and other systems, Home Assistant can pass device_info configuration values as floats (e.g., 255.0, 100.0) even when they should be integers. This caused "TypeError: 'float' object cannot be interpreted as an integer" when AutoCrop initialization accessed these values. Changes: - Convert offset values (offset_top, offset_down, offset_left, offset_right) to int - Convert size values (vacuum_status_size, mop_path_width) to int with error handling - Update TrimsData.from_dict(), from_json(), and from_list() to convert trim values to int - Update TrimCropData.from_dict() and from_list() to convert trim values to int Note: Color alpha values intentionally remain as floats in device_info and are converted to integers only when creating final RGBA tuples, so color handling is unaffected. ## Calibration Points Coordinate Swap Fix Fixed critical bug where X and Y coordinates were swapped in calibration points calculation. The crop_area format is [left, up, right, down], but get_vacuum_points() was incorrectly mapping crop_area[0] (left) to x and crop_area[1] (up) to y. Corrected mapping: - crop_area[1] (up) → x (was crop_area[0]) - crop_area[0] (left) → y (was crop_area[1]) Impact: - Robot position on map is now correctly placed - Touch-to-go coordinates work correctly - Room detection reports the correct room - Fixes issue where robot at x:3464, y:3262 was showing [3162, 3442] instead of [3442, 3162] ## Test Fixes - Fix typo in tests/test.py: trim_left 240.0 → 2400.0 ## Version - Bump version from 0.2.3 to 0.2.4b1 for beta testing in Home Assistant Files modified: - pyproject.toml - SCR/valetudo_map_parser/__init__.py - SCR/valetudo_map_parser/config/shared.py - SCR/valetudo_map_parser/config/types.py - SCR/valetudo_map_parser/config/utils.py - tests/test.py Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
Signed-off-by: SCA075 <82227818+sca075@users.noreply.github.com>
… version 0.2.4b3 release 🐛 Critical Bug Fixes: - Fixed calibration points not updating when map rotation changes * Removed incorrect rotation reordering logic in get_vacuum_points() * Calibration data now recalculates on every image generation * Ensures coordinate mapping works correctly at all rotation angles - Fixed segment alignment bug in map_data.py - Fixed rotation change handling to prevent "Invalid crop region" errors * Added rotation tracking to FloorData class * Detects when saved rotation differs from current rotation * Automatically resets trims for recalculation when rotation changes * Prevents errors when user changes rotation with saved floor data ✨ Implementation Details: - Added rotation: int field to FloorData class - update_trims() now saves current image_rotate with trims - On reload, compares saved rotation with current rotation - If different, resets trims to defaults and lets auto-crop recalculate - Logs rotation changes for debugging ✨ Updates: - Version bumped to 0.2.4b3 - Updated mvcrender dependency to 0.1.0 https://github.com/sca075/mvcrender/releases/tag/v0.1.0 - Comprehensive documentation updates (README.md, CHANGELOG.md) - New test: test_reload_rotation_change.py ✅ Quality Gate: - Pylint: 10.00/10 - All checks passed - Tests: PASSED * test_autocrop_floor.py: Calibration points correctly change with rotation * test_reload_rotation_change.py: Rotation change detection working, trims reset and recalculated * test.py: Image generation 432.6ms avg 📝 Modified Files: - SCR/valetudo_map_parser/config/types.py (rotation field in FloorData) - SCR/valetudo_map_parser/config/utils.py (update_trims with rotation, calibration fixes) - SCR/valetudo_map_parser/config/shared.py (rotation change detection) - tests/test_reload_rotation_change.py (new test) - pyproject.toml (version bump, mvcrender 0.1.0) - README.md (version and features update) - CHANGELOG.md (comprehensive v0.2.4 release notes with rotation change handling) Ready for Home Assistant testing. 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>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe pull request updates the project version from 0.2.4b8 to 0.2.4b9 in module metadata and project configuration. Additionally, two documentation comments were added to the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
This was referenced Feb 26, 2026
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 by CodeRabbit
Chores
Documentation