Set Dashboard Resource
ha_config_set_dashboard_resourceCreate or update Home Assistant dashboard resources from inline JavaScript/CSS or external URLs, supporting module, js, and css types.
Instructions
Create or update a dashboard resource (inline code or external URL).
Provide exactly one of:
content: Inline JavaScript or CSS code (embedded in the resource URL as a data: URI — no file storage or external hosting involved). Supports 'module' and 'css' types only (not 'js'); URLs are deterministic (same content = same URL); up to ~128KB. Content must be self-contained: a data: URI has no base URL, so relative imports inside a module and relative url() references inside CSS cannot resolve (use fully-qualified URLs instead). If Home Assistant is behind a reverse proxy that injects a Content-Security-Policy without 'data:' in script-src/style-src, the browser blocks these resources: this call still succeeds and the card simply never renders. Register the code as a file and use url='/local/...' on such a deployment. (HA itself ships no CSP.)
url: External resource URL — /local/... (files in /config/www/), /hacsfiles/... (HACS-installed cards) or https://... (CDN). Supports all types: 'module', 'js', 'css'.
EXAMPLES:
Inline: ha_config_set_dashboard_resource(content="class MyCard extends HTMLElement { ... } customElements.define('my-card', MyCard);", resource_type="module")
HACS card (after ha_manage_hacs(action='download')): ha_config_set_dashboard_resource(url="/hacsfiles/lovelace-mushroom/mushroom.js", resource_type="module")
Update: ha_config_set_dashboard_resource(url="/local/my-card-v2.js", resource_type="module", resource_id="abc123")
After adding a resource, a browser cache clear or hard refresh (Ctrl+Shift+R) is needed to load it.
If a Claude Desktop user gets a 4-minute timeout with no result on this call, read the target back before repeating it, and tell them to wait a few seconds before clicking the manual-approve button, as clicking it too quickly is known to cause hangs in Claude Desktop. This workaround is specific to Claude Desktop.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | No | URL of the resource. | |
| content | No | JavaScript or CSS code to host inline. | |
| resource_id | No | Resource ID to update. If omitted, creates a new resource. Get IDs from ha_config_list_dashboard_resources() | |
| resource_type | No | Resource type: 'module' for ES6 modules (modern cards), 'js' for legacy JavaScript (older custom cards), 'css' for stylesheets (themes, global styles) | module |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||