A custom Lovelace card for Home Assistant that lets you draw 2D detection zones over a grid and visualize tracked targets (for example, mmWave sensor targets). The card talks to the Zone Mapper backend integration, which persists the zones and exposes per‑zone occupancy sensors you can use in automations.
Warning
This integration requires the Zone Mapper backend integration for functionality. Install it from HACS or from the repository.
- Draw, update, and clear zones of multiple shapes: rectangle, ellipse, polygon
- Polygon drawing tools: double‑click to finish, Backspace to undo last vertex, Esc to cancel
- Polygon capped at 32 vertices (auto‑finishes at limit)
- Zones and rotation persist across Home Assistant restarts (restored from sensor attributes)
- Presence binary_sensors per zone using tracked X/Y entities
- Color‑coded zones and target dots; targets are rotated by the device angle for a consistent view
- Mobile‑friendly drawing (mouse + touch supported)
- Configurable grid ranges (default X: −5000..5000 mm, Y: 0..10000 mm; Y increases downward)
- Helper overlay (device “view cone”) with configurable horizontal FOV and rotation angle
- Compact UI:
- Bottom‑left: a single ✎ “Draw” button toggles a vertical menu of modes (▭ Rect, ◯ Ellipse, ⬠ Polygon) that appears above it
- Bottom‑right: 🔒 Lock toggle prevents accidental edits (disables drawing and cancels in‑progress)
- Device and Entity pickers: choose a HA device and select X/Y sensor entity pairs directly from dropdowns; click Apply to persist
- Multi‑unit support (front‑end only): configure input/grid in mm, cm, m, in, or ft (backend remains millimetres)
- Adaptive, unit‑aware grid spacing with readable “nice” steps
- Optional unit labels on axes (unit_display), with configurable font size (unit_label_size)
- Smart display units: mm grids label in metres; inch grids label in feet
- Device cone range rings and labels when unit_display is enabled: every 1 m (metric) or 4 ft (imperial)
- Caching of grid lines/labels and cone rings to reduce redraw work during drags/slider moves
- Home Assistant 2025.9.4+ recommended
- Zone Mapper backend integration installed
- Sensor entities providing numeric X and Y coordinates for one or more targets
There are two ways to install this lovelace card. Both this card and the backend integration must be installed
HACS is like an app store for Home Assistant. It makes installing and updating custom cards much easier. Here's how to install using HACS:
-
Install HACS if you don't have it:
- If HACS is not installed yet, download it following the instructions on https://hacs.xyz/docs/use/download/download/
- Follow the HACS initial configuration guide at https://hacs.xyz/docs/configuration/basic
-
Add this custom repository to HACS:
- Go to
HACSin your Home Assistant sidebar - CLick on the 3 dots in the upper right corner
- Click "Custom repositories"
- Add this URL to the repository: https://github.com/ApolloAutomation/zone-mapper-card
- Select
Dashboardfor the type - Click the
ADDbutton
- Go to
-
Install Zone Mapper:
- Go to
HACSin your Home Assistant sidebar - Search for
Zone Mapperin HACS - Click on the card when you find it
- Click the
Downloadbutton at the bottom right - Repeat for backend integration
- Go to
-
Copy the card file to your
wwwfolder:/config/www/zone-mapper-card.js
-
Add the resource in Settings → Dashboards → Resources:
- URL:
/local/zone-mapper-card.js - Type:
JavaScript Module
- URL:
-
Refresh your browser cache (Control/Command + Shift + Reload).
The Zone Mapper integration exposes a single service and creates two entity types per zone:
- Coordinate sensor:
sensor.zone_mapper_<slug(location)>_zone_<id>- Attributes:
shape,data,entities, androtation_deg - The card reads these to restore zones and rotation on load
- Attributes:
- Presence binary sensor:
<location> Zone <id> Presence(device class: Occupancy)
Shape data formats:
- Rect:
{ x_min, x_max, y_min, y_max } - Ellipse:
{ cx, cy, rx, ry } - Polygon:
{ points: [ { x, y }, ... ] }
To clear a zone, send data: null (or shape: none).
The majority of the configuration and management of zones takes place on the actual card interface. Location name, theme, grid sizing, and units are handled in the yaml:
type: custom:zone-mapper-card
location: Office # friendly name shown on card; used to build zone entity ids
dark_mode: false
# Units (front-end only, converts to mm internally)
input_units: mm # mm | cm | m | in | ft
grid_units: mm # mm | cm | m | in | ft
unit_display: false # show unit-aware axis labels and cone ring labels
unit_label_size: 18 # optional px (8..24)
# Zones can be managed in-card; you can optionally pre-seed a list here:
# zones: [ { id: 1, name: 'Zone 1' } ],
# Grid (units; Y‑down: y_min is top, y_max is bottom)
grid:
x_min: -6000
x_max: 6000
y_min: 0
y_max: 12000
# Device cone
device_cone:
y_max: 6000 # max range (radius) to display, in units
fov_deg: 120 # total horizontal FOV in degrees (e.g., 120 => ±60°)
angle_deg: 0 # initial rotation (-180..180); persisted and used for presence math- Click
Configuredrop-down - Click
Device and Targetsdrop-down - Select your device
- Entities attempt to auto-populate based off of device
- Entities can be manually configured for device
- For
Helper-type entities that aren't associated with adeviceleave device selection as default —Select device— and useAdd X/Y Pairto select entities
- Click
Applyto save selection.
- Click
Configuredrop-down - Click
Zonesdrop-down - Click
Add Zone - Name your new zone
- Click
Saveto confirm your new zone- Zones and their paired entities can be deleted here
- Zones can also be removed by restarting Home Assistant after removing the card and deleting from entities list
- Select a zone via its button.
- Click ✎ to reveal modes; choose ▭ Rect / ◯ Ellipse / ⬠ Poly.
- For Rect & Ellipse: click/touch and drag to define the bounding box; release to save.
- For Polygon: click to place vertices; double-click or click ✓ button to finish. Backspace and ↺ button removes the last vertex; Esc cancels the in-progress polygon.
- Max 32 points; reaching the limit auto-finishes the polygon.
- Double-click a zone button to clear just that zone (sends
data: null). - Use “Clear All Zones” to clear every configured zone. This does not delete entities
- Toggle 🔒 to lock/unlock drawing.
- Target dots are drawn in different colors using the current X/Y sensor values and are rotated by the current angle.
- Rotate the device fov cone with the slider (−180..180).
- Target positions rotate in-line with cone adjustment
- Double click slider handle to reset rotation to default defined with
angle_deg - This also updates backend
rotation_degand persists across restarts. The cone displays ±(fov_deg/2). Adjustcone.y_maxfor displayed range.
-
First, make sure you click
SaveandApplyafter setting up the card or making any changes -
“Resource not found”:
- Confirm the resource URL is
/local/zone-mapper-card.jsand the file is under/config/www. - Clear your browser cache.
- Confirm the resource URL is
-
Zones don’t persist:
- Check the coordinate sensor attributes for
shape,data, androtation_deg - Ensure
zone_mapper.update_zoneis being called (Developer Tools → States/Logs)
- Check the coordinate sensor attributes for
-
Coordinate entity not found:
- Draw a zone once to initialize entities for the location
-
Presence sensors never turn on:
- Verify tracked X/Y entity states are numeric (not
unknown/unavailable). - Confirm the point lies within the drawn zone (correct shape & coordinates).
- Verify tracked X/Y entity states are numeric (not
-
Targets dots are staying on card/triggering automations even though I have left the view:
- This is currently an issue with many ld2450 mmWave sensors using espHome, not related to Zone Mapper.
Zone Mapper creates simple binary presence entities for each location and zone. These can be quickly turned into automations using Home Assistant workflows:
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: binary_sensor.office_zone_1_presence
from: "off"
to: "on"
actions:
- alias: Turn on the light
action: light.turn_on
target:
entity_id: light.office_1
data: {}
- alias: Wait until there is no motion from device
wait_for_trigger:
trigger: state
entity_id: binary_sensor.office_zone_1_presence
from: "on"
to: "off"
- alias: Wait the number of seconds that has been set
delay: 120
- alias: Turn off the light
action: light.turn_off
target:
entity_id: light.office_1
data: {}
alias: Office Light Control
description: ""-
Entities are created on first update for a location; draw a zone once to initialize
-
Coordinates are rounded to the nearest millimeter by the backend
-
The
locationis slugified using Home Assistant's rules (lowercase, punctuation removed, accents stripped, spaces → underscores) to locate coordinate sensors:sensor.zone_mapper_<slug(location)>_zone_<id> -
Example:
location: "Office"→sensor.zone_mapper_office_zone_1
- The backend persists all geometry in millimetres using a Y‑down coordinate system (increasing Y goes down)
- The card converts between your configured input_units/grid_units and mm automatically
- Axis labels shorten mm→m and in→ft for legibility
- The canvas supports touch gestures (press, drag, lift) to draw zones.
- The card disables native touch scrolling on the canvas so you can draw without the page moving.
- If you can tap buttons but can’t draw, ensure you start the drag inside the canvas and lift to finish; also check whether another view/container intercepts gestures.
Single service: zone_mapper.update_zone.
Payload fields:
- location: string (required)
- zone_id: number (optional for zone updates; omit for angle‑only update)
- shape: 'none' | 'rect' | 'ellipse' | 'polygon' (optional; 'none' clears)
- data: object | null (optional; null clears the zone)
- rotation_deg: number (optional; −180..180; updates location angle when provided)
- entities: list of
{ x, y }entity id pairs (optional; replaces tracked entities for presence)
Examples:
Clear a zone:
service: zone_mapper.update_zone
data:
location: Office
zone_id: 1
shape: none
data: nullUpdate only rotation (no zone change):
service: zone_mapper.update_zone
data:
location: Office
rotation_deg: -15Update a rectangle and tracked entities:
service: zone_mapper.update_zone
data:
location: Office
zone_id: 2
shape: rect
data: { x_min: -500, x_max: 500, y_min: 500, y_max: 1500 }
entities:
- { x: sensor.device_target_1_x, y: sensor.device_target_1_y }
- { x: sensor.device_target_2_x, y: sensor.device_target_2_y }- The card is a vanilla JS Web Component; no build step is required.
- Edit
zone-mapper-card.jsand hard refresh your dashboard. - The backend is a standard Home Assistant custom component (binary_sensor + sensor platforms, custom services).

