added custom background image with path and other overlay support#922
Open
hansherlighed wants to merge 1 commit intoPiotrMachowski:masterfrom
Open
added custom background image with path and other overlay support#922hansherlighed wants to merge 1 commit intoPiotrMachowski:masterfrom
hansherlighed wants to merge 1 commit intoPiotrMachowski:masterfrom
Conversation
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.
Overview
This PR adds two major features to the Roborock Custom Map integration and lovelace-xiaomi-vacuum-map-card:
PR for RoborockCustomMap needed for this to work Lash-L/RoborockCustomMap#38
These work together to enable transparent vacuum overlays on top of static floor plans, replacing the official map with a custom rendering.
What's New
lovelace-xiaomi-vacuum-map-card Changes
map_sourcefields:background_image(string): URL of a static image to display underneath the mapmap_image_opacity(0.0–1.0): fade out the live map to reveal the backgroundbackground_image_calibration(1–3 point pairs): align the background to vacuum coordinates via affine/similarity/translation transformscomputeBackgroundMatrix()function for 1/2/3-point calibrationz-index: -1, map overlays rendered on topRoborockCustomMap Integration Changes
New options UI (settings → devices → Roborock Custom Map):
show_background,show_walls,show_rooms: control map layersshow_floor: hide MAP_INSIDE/MAP_SCAN/CARPETS/removed-area pixels (light green zones)Transparent rendering: with all backgrounds disabled +
show_floor=False, the rendered image contains only path, charger, and vacuum position on a transparent backgroundFloor color stripping (
_remove_floor_colors()): PIL post-processing that makes all floor-colored pixels fully transparent (alpha=0)Map rotation support: rotation stored in
hass.data, applied to both the image and calibration point coordinates so overlays stay alignedRace condition fix:
_custom_cached_mapis only written once after all processing (rendering + floor stripping + rotation), preventing concurrent requests from returning partially-processed imagesWhy This Approach
Frontend calibration (card) vs. backend rendering (integration)
background_image_calibration(1–3 points mapping background pixels to vacuum coordinates)Why rotation in the backend, not CSS
RestoreEntitysaves orientation across restartsWhy transparent rendering instead of cropping
show_floor=False, the custom extractor removes floor colors post-processing, leaving only important overlaysTechnical Details
File changes:
lovelace-xiaomi-vacuum-map-card changes:
src/types/types.ts: AddedBackgroundImageCalibrationPointinterface; added map_source fieldssrc/xiaomi-vacuum-map-card.ts: AddedcomputeBackgroundMatrix(); render<img id="background-image">; apply CSS matrix transform; wire up_updateBackgroundImageTransform()Backwards Compatibility
background_imageis optional; if not set, card behaves as beforeTested With