A custom Lovelace card for Home Assistant that displays beautiful heatmaps overlaid on background images. Perfect for visualizing temperature distributions, sensor data, or any numeric values across floor plans or other images.
- ๐ท Support for PNG, JPG, and SVG background images
- ๐ฅ Real-time heatmap rendering using simpleheat
- ๐งฉ Dynamic binding to Home Assistant entity values
- ๐ Configurable auto-update intervals
- ๐จ Customizable color gradients
- ๐ Auto-scaling with adjustable margins
- ๐ฌ Interactive tooltips showing values on hover
- ๐ Optional legend with customizable position
- ๐ฑ Responsive design for all devices
- ๐ก๏ธ Comprehensive error handling
Since this card is not yet in the HACS default repository, you'll need to add it as a custom repository:
- Open HACS in your Home Assistant instance.
- Go to "Frontend".
- Click the three dots in the top right corner and select "Custom repositories".
- In the dialog, paste the URL to this GitHub repository:
https://github.com/Seeed-Solution/lovelace-heatmap-card
- Select "Dashboard" as the category.
- Click "ADD".
- The card should now appear in the HACS Frontend section. Click on it.
- Click "INSTALL THIS REPOSITORY IN HACS".
- Click "INSTALL".
- Restart Home Assistant if prompted or if the card doesn't load immediately.
-
Download
heatmap-card.js
from the latest release. -
Copy the downloaded
heatmap-card.js
file into your Home Assistantconfig/www/
directory. (If thewww
directory doesn't exist, create it.) -
Add the card as a resource in your Lovelace configuration. This tells Home Assistant where to find the card's code. To do this via the UI (recommended for most users): a. Go to Settings > Dashboards. b. Select the dashboard you want to add the card to (or create a new one). c. Click the three dots (โฎ) in the top right and choose "Edit dashboard". d. Click the three dots (โฎ) again and choose "Manage resources". e. Click the "+ ADD RESOURCE" button (usually in the bottom right). f. Enter the following: - URL:
/local/heatmap-card.js
- Resource type:JavaScript Module
g. Click "CREATE".Alternatively, if you manage your Lovelace configuration in YAML mode, add the following to the
resources
section of yourui-lovelace.yaml
or dashboard YAML file:resources: - url: /local/heatmap-card.js type: module
-
Refresh Home Assistant: You might need to refresh your browser or restart Home Assistant for the new resource to be loaded correctly.
Add this to your Lovelace dashboard:
type: custom:heatmap-card
background: /local/floorplan.png
points:
- x: 120
y: 100
entity_id: sensor.living_room_temperature
label: "Living Room"
- x: 320
y: 180
entity_id: sensor.kitchen_temperature
label: "Kitchen"
- x: 200
y: 300
entity_id: sensor.bedroom_temperature
label: "Bedroom"
Name | Type | Default | Description |
---|---|---|---|
background |
string | Required | Path to background image |
points |
array | Required | Array of heatmap points |
width |
number | auto | Card width in pixels |
height |
number | auto | Card height in pixels |
Name | Type | Default | Description |
---|---|---|---|
radius |
number | 40 | Heat point radius (min: 1) |
blur |
number | 15 | Additional blur radius in pixels (min: 0) |
opacity |
number | 0.6 | Heatmap opacity (0-1) |
gradient |
object | BlueโGreenโRed | Color gradient configuration |
Name | Type | Default | Description |
---|---|---|---|
auto_scale |
boolean | false | Enable automatic value scaling |
scale_margin |
number | 0 | Margin percentage for auto-scaling (0-50) |
min_value |
number | 0 | Manual minimum value |
max_value |
number | 100 | Manual maximum value |
Name | Type | Default | Description |
---|---|---|---|
show_legend |
boolean | false | Show color scale legend |
legend_unit |
string | "" | Unit text for legend |
show_labels |
boolean | false | Show value labels on points |
update_interval |
number | 30 | Update interval in seconds (5-3600) |
Each point in the points
array supports:
Name | Type | Required | Description |
---|---|---|---|
x |
number | โ | X coordinate on image |
y |
number | โ | Y coordinate on image |
entity_id |
string | โ | Home Assistant entity ID |
value |
number | โ | Static value (if no entity_id) |
label |
string | โ | Display label |
weight |
number | โ | Point weight multiplier (0.1-2.0) |
Note: Each point must have either entity_id
or value
, but not both.
This example demonstrates a more complex layout for an office, showing potential people flow or occupancy.
type: custom:heatmap-card
background: /local/images/firewood_fp.jpg # User needs to place firewood_fp.jpg in config/www/images/
points:
- x: 220
y: 100
entity_id: sensor.your_temperature_sensor # Replace with your actual sensor
label: Communication
- x: 300
y: 250
value: 8
label: Meeting
weight: 0.8
- x: 300
y: 180
value: 15
label: Office
weight: 0.8
- x: 120
y: 140
value: 5
label: WorkingArea1
weight: 0.8
- x: 120
y: 230
value: 8
label: WorkingArea2
weight: 0.8
- x: 220
y: 160
value: 15
label: Exhibition
weight: 0.8
- x: 220
y: 260
value: 20
label: Entrance
weight: 0.8
radius: 40
blur: 30
opacity: 0.7
auto_scale: true
scale_margin: 10
update_interval: 30 # In seconds
show_legend: true
legend_unit: ""
show_labels: true
error_message: Error loading heatmap data.
gradient:
"0.0": "#d3d3d3" # Corrected from "0"
"0.3": "#ffff00"
"1.0": "#ff0000" # Corrected from "1"
Create custom gradients by specifying color stops at positions from 0 to 1:
gradient:
0.0: "#ffffff" # White at minimum
0.2: "#ffcccc" # Light red
0.4: "#ff9999" #
0.6: "#ff6666" #
0.8: "#ff3333" #
1.0: "#ff0000" # Red at maximum
Cool to Warm:
gradient:
0.0: "#001f3f" # Navy
0.25: "#0074D9" # Blue
0.5: "#39CCCC" # Teal
0.75: "#FFDC00" # Yellow
1.0: "#FF4136" # Red
Monochrome:
gradient:
0.0: "#ffffff" # White
0.5: "#888888" # Gray
1.0: "#000000" # Black
To find the correct x,y coordinates for your points:
- Open your background image in an image editor
- Note the pixel coordinates where you want to place heat points
- If using
width
/height
settings, scale coordinates proportionally - Use browser developer tools to fine-tune positions
- Check the image path is correct
- Ensure the image is in
/config/www/heatmap-card/
for local images - Use
/local/heatmap-card/
prefix for local images
- Verify entity IDs are correct
- Check entities exist in Developer Tools > States
- Ensure entity values are numeric
- Check browser console for errors
- Verify at least one point has a valid value
- Try increasing radius or opacity
If you want to contribute to the development of this card or make your own customizations, follow these steps:
-
Clone the Repository:
git clone https://github.com/Seeed-Solution/lovelace-heatmap-card.git cd lovelace-heatmap-card
-
Install Dependencies: This project uses Node.js and npm. Make sure you have them installed. Then, install the project dependencies:
npm install
-
Build the Card: To build the
heatmap-card.js
file from the source code, run:npm run build
This will compile the TypeScript code and bundle it into the
dist/
directory. -
Development Workflow (Watch for changes): To automatically rebuild the card whenever you make changes to the source files in
src/
, use:npm run dev
This is useful during development as it keeps the
dist/heatmap-card.js
file up-to-date. You can then copy this file to your Home Assistantwww
directory to test your changes.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- simpleheat for the lightweight and efficient heatmap library
- Home Assistant community for inspiration and feedback
- All contributors and users of this card