Julian Edlinger 2ee83993b7 Fix rotation conflicts between multiple Roborock devices (#40)
* Add map rotation constants

Introduce rotation configuration constants for map image handling.
Adds rotation options (0, 90, 180, 270) and dispatcher signal name.

* Add per-map rotation select entity

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.

* Enable rotation select platform and initialize storage

Register SELECT platform and initialize rotation storage in hass.data.
Add proper unload cleanup and reload behavior.

* Add backend map rotation with executor offloading

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 translations for rotation select entity

Add English and German translations for map rotation select entity.
Includes user-friendly labels for rotation options.

* Document map rotation select entity in README

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.

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Store rotation state per device and map instead of only map_flag.

This prevents multiple Roborock devices with identical map_flag values
from sharing rotation state and dispatcher signals.

* Fix image rotation lookup for multiple Roborock devices

* Fix thread-safe state update on rotation change

I found and fixed a thread-safety issue in the rotation update signal.

The image entity now schedules the state update back onto the Home Assistant event loop before calling `async_write_ha_state()`, instead of calling it directly from the dispatcher callback.

---------

Co-authored-by: Luke Lashley <conway220@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-06-01 13:15:48 -04:00
2025-04-03 01:07:31 +02:00
2025-03-22 11:15:33 -04:00
2025-12-05 19:37:49 -05:00

Roborock Custom Map

you MUST be on 2025.4b or later

This allows you to use the core Roborock integration with the Xiaomi Map Card

If you would like to support me, you can do so here:

BuyMeCoffee

PaypalMe

Setup

  1. Install the Roborock Core Integration and set it up
  2. It is recommended that you first disable the Image entities within the core integration. Open each image entity, hit the gear icon, then trigger the toggle by enabled.
  3. Install this integration(See the installing via HACS section below)
  4. This integration works by piggybacking off of the Core integration, so the Core integration will do all the data updating to help prevent rate-limits. But that means that the core integration must be setup and loaded first. If you run into any issues, make sure the Roborock integration is loaded first, and then reload this one.
  5. Setup the map card like normal! An example configuration would look like
type: custom:xiaomi-vacuum-map-card
vacuum_platform: Roborock
entity: vacuum.s7
map_source:
  camera: image.s7_downstairs_full_custom
calibration_source:
  camera: true

Map rotation (new)

If your map is displayed sideways or upside down, you can rotate the map directly in Home Assistant.

This integration provides a Select entity per map to control rotation:

  • select.<...>_rotation
  • Options: , 90°, 180°, 270° (labels depend on your HA language)

This rotates both:

  • the map image
  • and the calibration points used by the Xiaomi Vacuum Map Card
    (so rooms/zones and interactions stay aligned after rotation)

How to use

  1. Go to Settings → Devices & services → Roborock Custom Map
  2. Open the device/entities list
  3. Find the … rotation select entity for your map and choose the correct rotation

No reload is required; the map updates immediately.

  1. You can hit Edit on the card and then Generate Room Configs to allow for cleaning of rooms. It might generate extra keys, so check the yaml and make sure there are no extra 'predefined_sections'

Installation

Installing via HACS

Open your Home Assistant instance and open a repository inside the Home Assistant Community Store.

or

  1. Go to HACS->Integrations
  2. Add this repo(https://github.com/Lash-L/RoborockCustomMap) into your HACS custom repositories
  3. Search for Roborock Custom Map and Download it
  4. Restart your HomeAssistant
  5. Go to Settings->Devices & Services
  6. Add the Roborock Custom Map integration

Alternative/optional

Once you set up this integration, you can generate a static config in the lovelace card, and theoretically, you should be able to use that code with your Roborock CORE integration. However, it wont stay up to date if the map calibrations change significantly, or rooms change. So I'd only do this when I was sure everything was good!

S
Description
Add support for working with Piotr Machowski's map card for the official Roborock integration
Readme 82 KiB
Languages
Python 100%