Skip to content

Comments

Add per-map rotation support with select entity and calibrated overlays#37

Open
TheHangMan97 wants to merge 6 commits intoLash-L:mainfrom
TheHangMan97:main
Open

Add per-map rotation support with select entity and calibrated overlays#37
TheHangMan97 wants to merge 6 commits intoLash-L:mainfrom
TheHangMan97:main

Conversation

@TheHangMan97
Copy link

Overview

This PR adds per-map rotation support to the Roborock Custom Map integration.

Instead of handling rotation in the frontend, this implementation introduces a
dedicated Select entity per map that allows users to rotate the map image
directly within Home Assistant.

What’s new

  • Per-map rotation via Select entity (0°, 90°, 180°, 270°)
  • Live updates (no reload required)
  • Rotation persisted across restarts
  • Image rotation handled in executor (non-blocking)
  • Calibration points rotated together with the image
  • Rooms/zones remain correctly aligned after rotation
  • English and German translations included

Why this approach

Frontend-only rotation (CSS/card-mod) rotates only the rendered pixels and
does not adjust calibration or interaction coordinates.

This implementation rotates:

  • the image bytes
  • the calibration map coordinates

so overlays and interactions (rooms, zones, taps) stay aligned.

Technical details

  • Rotation stored in hass.data per map_flag
  • Select entity uses RestoreEntity for persistence
  • Dispatcher signal triggers image cache bust on rotation change
  • PNG dimensions extracted directly from header for efficient calibration adjustment
  • Image processing offloaded via async_add_executor_job

Backwards compatibility

  • Default behavior unchanged (no rotation = 0°)
  • Existing entities unaffected
  • Rotation is optional and disabled by default

Tested with

  • Xiaomi Vacuum Map Card
  • Multiple maps (per floor)
  • Calibration overlays
  • Room and zone interactions

Introduce rotation configuration constants for map image handling.
Adds rotation options (0, 90, 180, 270) and dispatcher signal name.
Add SelectEntity to control map rotation per map_flag.
Rotation value is persisted via RestoreEntity and stored in hass.data.
Dispatcher signal notifies image entities when rotation changes.
Register SELECT platform and initialize rotation storage in hass.data.
Add proper unload cleanup and reload behavior.
Implement backend image rotation using Pillow.
Rotation is applied in async_add_executor_job to avoid blocking the event loop.
Includes defensive validation and fallback handling.
Add English and German translations for map rotation select entity.
Includes user-friendly labels for rotation options.
Add documentation for the per-map rotation select entity.

Explains:
- How to rotate maps (0/90/180/270)
- Where to find the rotation select entity
- That calibration points are rotated as well
- That no reload is required

Also clarifies usage with Xiaomi Vacuum Map Card.
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.

1 participant