Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Rooms Colours and AutoCrop trim data #325

Merged
merged 4 commits into from
Feb 10, 2025
Merged

Issue with Rooms Colours and AutoCrop trim data #325

merged 4 commits into from
Feb 10, 2025

Conversation

sca075
Copy link
Owner

@sca075 sca075 commented Feb 9, 2025

Issue with Rooms Colours and AutoCrop trim data solved in the libray valetudo_map_parser. Still need to complete the reset and save trims phase.

Summary by CodeRabbit

  • New Features
    • Improved migration process for a smoother configuration upgrade.
    • Enhanced camera integration with additional attributes for clearer device status and functionality.

  • Bug Fixes / Enhancements
    • Refined error handling in service operations to reduce disruptions.
    • Streamlined room management and renaming for improved setup experience.

  • Chores
    • Updated version numbers, dependencies, and configuration defaults for overall stability.
    • Added new configuration key for improved settings management.
    • Adjusted logging for better clarity during operations.

@sca075 sca075 self-assigned this Feb 9, 2025
Copy link

coderabbitai bot commented Feb 9, 2025

Walkthrough

This pull request updates version numbers across the component and introduces a new asynchronous migration function for configuration entries, transitioning from version 3.1 to 3.2. Logging styles have been standardized, and the MQTTCamera class has been enhanced with new properties to provide better access to its state. The utilization of RoomStore has been refactored in both the connector and file operations modules. Additionally, error handling in the vacuum services has shifted from raising exceptions to logging warnings.

Changes

File(s) Change Summary
custom_components/mqtt_vacuum_camera/init.py Updated version number from 2024.12.0 to 2025.2.1; added async_migrate_entry for configuration entry migration (3.1→3.2); replaced f-string logging with % formatting.
custom_components/mqtt_vacuum_camera/camera.py Added new properties (name, model, brand, is_on, frame_interval, is_streaming, supported_features, extra_state_attributes, should_poll, device_info); updated return type of empty_if_no_data from Image.Image to Image.
custom_components/mqtt_vacuum_camera/config_flow.py Updated module and handler version (2024.12.0→2025.2.1 and 3.1→3.2); modified room count retrieval by instantiating RoomStore and logging the count.
custom_components/mqtt_vacuum_camera/const.py
custom_components/mqtt_vacuum_camera/manifest.json
In const.py, updated version (v2024.12.0→2025.2.1) and added a new "trims_data" key to DEFAULT_VALUES with corresponding update in KEYS_TO_UPDATE; in manifest.json, updated version (2024.2.0b0→2025.2.1) and dependency version for valetudo_map_parser (0.1.9.b23→0.1.9.b35).
custom_components/mqtt_vacuum_camera/utils/MQTT/connector.py
custom_components/mqtt_vacuum_camera/utils/files_operations.py
custom_components/mqtt_vacuum_camera/utils/vacuum/mqtt_vacuum_services.py
Refactored RoomStore instantiation and method calls (renamed async_set_rooms_data to set_rooms and removed file_name parameter); updated versions; in mqtt_vacuum_services.py, replaced exception raising for validation errors with warning logs.

Sequence Diagram(s)

sequenceDiagram
    participant HA as Home Assistant
    participant Migrate as async_migrate_entry
    participant CE as Config Entry
    participant Log as Logger
    HA ->> Migrate: Initiate migration for config entry
    Migrate ->> Log: Log migration start
    Migrate ->> Migrate: Check for existing options
    alt Options found
        Migrate ->> CE: Update entry with new data and options
        Migrate ->> Log: Log successful migration
    else No options found
        Migrate ->> Log: Log error: migration failed
    end
Loading
sequenceDiagram
    participant Service as vacuum_clean_zone
    participant Validator as Validation Logic
    participant Log as Logger
    Service ->> Validator: Validate service parameters
    alt Validation passes
        Service ->> Service: Proceed with cleaning zone
    else Validation fails
        Service ->> Log: Log warning about validation error
        Service ->> Service: Continue execution without raising exception
    end
Loading

Possibly related PRs


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc4c4cf and 507eba2.

📒 Files selected for processing (2)
  • custom_components/mqtt_vacuum_camera/camera.py (2 hunks)
  • custom_components/mqtt_vacuum_camera/utils/vacuum/mqtt_vacuum_services.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • custom_components/mqtt_vacuum_camera/utils/vacuum/mqtt_vacuum_services.py
  • custom_components/mqtt_vacuum_camera/camera.py

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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)
custom_components/mqtt_vacuum_camera/utils/vacuum/mqtt_vacuum_services.py (1)

146-152: Consider keeping validation errors for critical issues.

While switching to warning logs makes the code more forgiving, consider keeping ServiceValidationError for critical validation failures that could lead to incorrect behavior.

-        _LOGGER.warning("Validation Error: %s", got_error)
+        if got_error in ["missing_zone_or_zone_ids", "zone_list_length"]:
+            raise ServiceValidationError(
+                translation_domain=DOMAIN,
+                translation_key=got_error,
+            )
+        else:
+            _LOGGER.warning("Validation Error: %s", got_error)
custom_components/mqtt_vacuum_camera/utils/files_operations.py (1)

265-266: Consider using async method for room data retrieval 🤔

The synchronous get_rooms() call might block the event loop. Consider using an async method to maintain consistency with Home Assistant's async patterns.

-    rooms = RoomStore(vacuum_id)
-    room_data = rooms.get_rooms()
+    rooms = RoomStore(vacuum_id)
+    room_data = await rooms.async_get_rooms()
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b94124f and d31bfbe.

📒 Files selected for processing (8)
  • custom_components/mqtt_vacuum_camera/__init__.py (5 hunks)
  • custom_components/mqtt_vacuum_camera/camera.py (2 hunks)
  • custom_components/mqtt_vacuum_camera/config_flow.py (3 hunks)
  • custom_components/mqtt_vacuum_camera/const.py (3 hunks)
  • custom_components/mqtt_vacuum_camera/manifest.json (1 hunks)
  • custom_components/mqtt_vacuum_camera/utils/MQTT/connector.py (3 hunks)
  • custom_components/mqtt_vacuum_camera/utils/files_operations.py (3 hunks)
  • custom_components/mqtt_vacuum_camera/utils/vacuum/mqtt_vacuum_services.py (2 hunks)
🧰 Additional context used
📓 Learnings (3)
custom_components/mqtt_vacuum_camera/__init__.py (1)
Learnt from: sca075
PR: sca075/mqtt_vacuum_camera#251
File: custom_components/mqtt_vacuum_camera/camera.py:239-245
Timestamp: 2024-11-12T05:06:42.185Z
Learning: Ensure to verify the presence of decorators before suggesting their removal in code reviews.
custom_components/mqtt_vacuum_camera/manifest.json (2)
Learnt from: sca075
PR: sca075/mqtt_vacuum_camera#310
File: custom_components/mqtt_vacuum_camera/manifest.json:10-13
Timestamp: 2025-01-30T23:41:28.893Z
Learning: For packages that are ultimately controlled by Home Assistant's dependency management (like Pillow), it's acceptable to set a future upper version bound to reduce maintenance overhead, as HA will ensure compatibility.
Learnt from: sca075
PR: sca075/mqtt_vacuum_camera#256
File: custom_components/mqtt_vacuum_camera/manifest.json:11-11
Timestamp: 2024-11-12T05:06:42.185Z
Learning: In this project, the `CHANGELOG.md` file is not considered necessary.
custom_components/mqtt_vacuum_camera/config_flow.py (2)
Learnt from: sca075
PR: sca075/mqtt_vacuum_camera#196
File: custom_components/mqtt_vacuum_camera/config_flow.py:352-355
Timestamp: 2024-11-12T05:06:42.185Z
Learning: Changes in `config_flow.py` now include handling for `floor_only` and `alpha_floor` steps based on the number of rooms, ensuring proper configuration and error handling for unexpected values of `number_of_rooms`.
Learnt from: sca075
PR: sca075/mqtt_vacuum_camera#196
File: custom_components/mqtt_vacuum_camera/translations/en.json:132-140
Timestamp: 2024-11-12T05:06:42.185Z
Learning: Changes in `config_flow.py` related to adding steps for `floor_only` and `alpha_floor` configurations resolve the issue with the `floor_only` section in the translation files.
🔇 Additional comments (15)
custom_components/mqtt_vacuum_camera/__init__.py (3)

2-2: Version bump looks good!

Version updated to 2025.2.1 to reflect the new changes.


123-123: Nice logging format update!

Switched to % style formatting for logs, which is more efficient and consistent with Python logging best practices.

Also applies to: 148-148, 154-154


171-203: 🏁 Script executed:

#!/bin/bash
# Check for any existing config entries that might need migration
rg -A 5 "version.*3\.1" .storage/

Length of output: 85

custom_components/mqtt_vacuum_camera/const.py (2)

2-2: Good addition of trims_data configuration!

The new trims_data structure is well-defined with default values for all trim directions.

Also applies to: 99-99


161-161: Nice integration of trims_data in update keys!

Added trims_data to KEYS_TO_UPDATE to ensure it's properly handled during configuration updates.

custom_components/mqtt_vacuum_camera/utils/MQTT/connector.py (2)

60-60: LGTM! Clean refactor of RoomStore instantiation.

The file_name parameter is now passed during RoomStore instantiation instead of per method call, which is a cleaner approach.


254-256: LGTM! Consistent refactoring of set_rooms calls.

The set_rooms method calls have been updated to match the refactored RoomStore interface, removing redundant file_name parameters.

Also applies to: 308-308

custom_components/mqtt_vacuum_camera/camera.py (1)

282-282: LGTM! More flexible type annotation.

Changed return type from Image.Image to Image to be more flexible and less restrictive.

custom_components/mqtt_vacuum_camera/config_flow.py (2)

355-357: LGTM! Consistent RoomStore usage.

The RoomStore instantiation and method calls have been updated to match the refactored interface, maintaining consistency across the codebase.


108-108: Version bump to 3.2.

Make sure there's a migration path for users upgrading from version 3.1.

Run this script to check for migration code:

✅ Verification successful

🏁 Script executed:

#!/bin/bash
# Description: Check for migration code from version 3.1 to 3.2

# Search for migration code
rg -A 5 "async_migrate_entry|async def migrate|VERSION = 3.1"

Length of output: 625


Migration code for version bump to 3.2 is in place.

The migration function in init.py correctly checks for version 3.1 and processes an entry upgrade to version 3.2, ensuring a proper migration path for users upgrading from version 3.1.

custom_components/mqtt_vacuum_camera/manifest.json (2)

14-14: LGTM! Version bump to 2025.2.1.

The version follows the year.month.patch format and is consistent across all files.


13-13: Verify compatibility with valetudo_map_parser 0.1.9.b34.

Check the changelog for any breaking changes in the new version.

✅ Verification successful

🌐 Web query:

What are the changes in valetudo_map_parser version 0.1.9.b34?

💡 Result:

The provided search results do not contain specific information about changes in `valetudo_map_parser` version **0.1.9.b34**. While several sources mention Valetudo-related tools and integrations (e.g., Node-RED nodes for map conversion[3][5], development instructions[4], and capabilities documentation[7][8]), none explicitly address this particular version of `valetudo_map_parser`.

For details on **version 0.1.9.b34**, you would need to consult:
- The GitHub repository for `sca075/Python-package-valetudo-map-parser`[6], which likely contains commit history or release notes for this package.
- Official Valetudo documentation or community forums for updates to map-parsing utilities.

If this version was released after January 2025 (the latest commit date in result [6]), it may not be reflected in the current search results provided here[1-9].

Citations:

- 1: https://github.com/Hypfer/Valetudo/releases
- 2: https://newreleases.io/project/github/Hypfer/Valetudo/release/2021.02.0
- 3: https://flows.nodered.org/node/node-red-contrib-valetudo
- 4: https://valetudo.cloud/pages/development/building-and-modifying-valetudo.html
- 5: https://truecharts.org/charts/stable/valetudo-mapper/
- 6: https://github.com/sca075/Python-package-valetudo-map-parser
- 7: https://valetudo.cloud/pages/usage/capabilities-overview.html
- 8: https://valetudo.cloud/pages/general/supported-robots.html
- 9: https://community.home-assistant.io/t/valetudo-map-card-installation-instructions/247329?page=2

Update on valetudo_map_parser 0.1.9.b34 Compatibility
Based on the web search, there isn't any explicit documentation showing breaking changes or incompatibilities with version 0.1.9.b34. While detailed release notes weren't found in the available search results, it’s a good idea to verify the upstream GitHub repository (sca075/Python-package-valetudo-map-parser) for any commit-level details or notes that might impact compatibility.

  • The dependency update on line 13 appears in line with the overall update (as the version in the manifest follows the year.month.patch scheme).
  • No explicit breaking changes have been identified from the available sources.
  • I recommend a quick manual check of the official release notes on the GitHub repo for peace of mind.

Everything seems cool so far!

custom_components/mqtt_vacuum_camera/utils/files_operations.py (3)

7-7: Version number looks good! 🚀

The version has been updated to 2025.02.1, which aligns with the current date.


289-312: Sweet improvements to room handling! 🎯

Nice enhancements:

  • Preserved original room order
  • Added fallback for missing room names
  • Cleaned up unused entries for better data hygiene

284-343: Error handling is on point! 💪

Great improvements to error handling and user feedback:

  • More informative warning messages for missing translations
  • Better language fallback mechanism

…075/refactoring_camera

updated manifest with the correct version of map_parser
@sca075 sca075 merged commit 9e425a8 into main Feb 10, 2025
6 checks passed
@sca075 sca075 linked an issue Feb 10, 2025 that may be closed by this pull request
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rooms Colours Configuration not working properly.
1 participant