You are reading the development docs (2026.12.1-dev.1): features here may not be released yet.
Skip to content

Home Assistant Integration Architecture ​

LCARdS ships as a HACS integration (custom_components/lcards/). This page is the Python-side view: how the integration boots, what it registers in Home Assistant (static paths, WebSocket commands, actions, the sidebar panel, a media source), how the browser bundle is served and loaded, and how the backend talks to the browser.

The browser side of the same conversation has its own pages; this page links them instead of repeating them:


Two-Layer Architecture ​

media_source.py is not wired up by __init__.py: Home Assistant's media_source integration discovers it (see Media Source Platform). diagnostics.py is discovered the same way by Home Assistant's diagnostics integration.


Python Component Files ​

FileResponsibility
__init__.pyEntry point: the minimum Home Assistant version gate, static paths and WebSocket commands (async_setup), then log level, storage, actions, JS injection, sidebar panel and the options listener (async_setup_entry), and the matching cleanup (async_unload_entry)
frontend.pyRegisters the two static paths, injects lcards.js?v=<version>&log=<level> with add_extra_js_url, keeps one Lovelace module resource for Cast, and removes legacy resource entries
config_flow.pySingle-instance setup flow (no input) and the options flow (panel, title, icon, log level, preview features)
websocket_api.pyRegisters the 30 lcards/* WebSocket commands (probe, global storage, push channel, scoped storage, event relay, device palettes, fonts, diagnostics)
fonts.pyPure rules for the font manager: file names and formats, font metadata (family, weight, style from TTF, OTF, WOFF and WOFF2), the fonts record and the user fonts stylesheet (Font Manager)
font_store.pyThe fonts record in storage, the fonts folder listing, the fonts_changed event
font_views.pyHTTP views: the user fonts stylesheet (/api/lcards/fonts.css) and the admin upload (/api/lcards/fonts/upload)
palette.pyPure rules for device palettes: cleaning, lookup by device name, when a write announces palette_changed (Kiosk Satellite Bridge)
services.pyRegisters the 18 lcards.* actions: alert modes, frontend control, screen effects, sound, astrometrics, portal overlays and the Borg Easter egg
services.yamlAction names, descriptions and field selectors shown in Developer tools > Actions and the automation editor
storage.pyLCARdSStorage: a flat key/value store on Home Assistant's Store helper (.storage/lcards), with the _user_<id> / _device_<id> record helpers
media_source.pyLCARdSMediaSource: a read-only "LCARdS" folder in Home Assistant's media browser (bundled images, sounds, ship blueprints, models, and the user's own models)
support.pyasync_collect_backend_diagnostics(): the backend facts shared by lcards/diagnostics and Download diagnostics
diagnostics.pyasync_get_config_entry_diagnostics(): Home Assistant's Download diagnostics for the config entry, returns the support.py facts
const.pyDOMAIN, MIN_HA_VERSION, DOMAIN_VERSION, the user folder paths, option keys and defaults, storage namespaces, _LOG_LEVEL_MAP
manifest.jsonDomain, version (Home Assistant CalVer, no suffix), dependencies: [http, lovelace], after_dependencies: [media_source], single_config_entry: true, iot_class: local_push
strings.json, translations/en.jsonText of the setup and options dialogs
THIRD_PARTY_NOTICES.txtLicence notices of the libraries built into the bundle (generated, see Bundle and loading)

hacs.json (repository root) tells HACS to install the release asset lcards.zip (zip_release, filename) and sets the minimum Home Assistant version HACS checks before installing ("homeassistant": "2026.11.0").


Minimum Home Assistant Version ​

LCARdS needs Home Assistant 2026.11 or newer. The value lives in three places that must agree:

WhereValueEffect
const.py:9 MIN_HA_VERSION(2026, 11)async_setup() compares it with homeassistant.const MAJOR_VERSION, MINOR_VERSION and, when the running version is older, logs an error ("LCARdS requires Home Assistant 2026.11 or newer ...") and returns False (__init__.py:61-67). Nothing is registered: no static paths, no WebSocket commands, and the config entry does not set up
hacs.json homeassistant2026.11.0HACS refuses to install or update on an older Home Assistant
src/utils/support-info-format.js:16 MIN_HA_VERSION[2026, 11]The Welcome tab health check marks an older Home Assistant as an error (see Support and diagnostics)

tests/support/min-ha-version.test.js fails when the three differ (and when manifest.json grows a homeassistant key of its own: custom integrations cannot declare a minimum there). support.py reports the Python value as versions.min_home_assistant.


Boot Sequence ​

Home Assistant calls the integration in two phases.

Phase 1: async_setup() (Home Assistant start, before the config entry) ​

__init__.py:54-76. Runs once per Home Assistant start, whether or not the integration has been set up yet:

  1. Version gate: returns False below MIN_HA_VERSION (see above).
  2. Static paths: async_register_static_path(hass) registers /lcards and /lcards-user (see Static Paths). It creates <config>/www/lcards/models first if it is missing.
  3. WebSocket commands: async_setup_ws(hass) registers all 30 lcards/* commands (websocket_api.py:123-164), so lcards/info answers even before a config entry exists. Commands that need storage answer storage_unavailable until Phase 2 has run.
  4. Font views: async_register_font_views(hass) registers the user fonts stylesheet and the upload view (see Font Manager).
  5. hass.data["lcards"] is created (setdefault), so storage and frontend.py can write into it later.

Phase 2: async_setup_entry() (config entry active) ​

__init__.py:133-176. Runs after the setup flow and on every start or reload with the entry configured:

  1. Log level: maps the log_level option through _LOG_LEVEL_MAP and calls setLevel() on the custom_components.lcards logger, so every child logger follows.
  2. Storage: await LCARdSStorage(hass).async_load() reads .storage/lcards; the instance goes to hass.data["lcards"]["storage"].
  3. Actions: await async_setup_services(hass) registers the 18 lcards.* actions.
  4. JS injection: async_register_frontend_script_resource(hass, log_level) (frontend.py:82-163):
    • builds resource_url = /lcards/lcards.js?v=<DOMAIN_VERSION>&log=<level> and keeps it in hass.data["lcards"]["resource_url"] (unload needs the exact string);
    • add_extra_js_url(hass, resource_url) loads the script on every Home Assistant page;
    • in the Lovelace resources collection: deletes legacy entries whose URL starts with /hacsfiles/lcards/lcards.js or /local/community/lcards/lcards.js (the old HACS frontend-plugin install, which would load the bundle twice); updates an existing /lcards/lcards.js... entry when its URL differs (new version or log level); otherwise creates one module resource. The resource is there for Cast and kiosk views that do not run extra_js_url.
  5. Sidebar panel: when show_panel is on, _register_panel() registers a custom panel at /lcards-config with the configured title and icon, element lcards-config-panel, module_url = the same resource_url, and require_admin=False (__init__.py:79-119). The panel reuses the injected URL on purpose: a different URL (for example the bare /lcards/lcards.js) is a different ES module to the browser, which would run a second copy of the bundle with its own singletons.
  6. Options listener: entry.add_update_listener(_async_options_updated) reloads the entry when options are saved, so changes apply without a restart.

Unload: async_unload_entry() ​

__init__.py:179-197. Called on restart, on reload (including an options change) and before removal:

  1. async_remove_services(hass) removes the 18 actions.
  2. async_remove_frontend_script_resource(hass) calls remove_extra_js_url with the stored URL, clears it from hass.data, and deletes every /lcards/lcards.js... Lovelace resource (it loops over a copy of the items: in YAML resource mode async_items() is the collection's own list, and removing from it while looping skipped the next entry).
  3. async_remove_panel(hass, "lcards-config") (errors ignored during shutdown).

The static paths, the WebSocket commands and the storage instance in hass.data stay until Home Assistant stops: Home Assistant cannot unregister them. A reload creates a fresh LCARdSStorage from disk and overwrites the stored instance. async_remove_entry() does nothing.


Static Paths ​

frontend.py:43-79 registers two paths in one hass.http.async_register_static_paths() call (a RuntimeError for an already registered path, after removing and re-adding the integration without a restart, is ignored):

URLFolderCache headersPurpose
/lcards<config>/custom_components/lcards/yes (public, max-age of 31 days)The whole integration folder: the bundle and everything it loads
/lcards-user<config>/www/lcards/ (USER_DIR)noThe LCARdS user folder: files users add themselves, models/ (MY_MODELS_URL = /lcards-user/models) and fonts/ (MY_FONTS_URL = /lcards-user/fonts, bring-your-own fonts named after their key, which the font CSS tries before its fallback)

What /lcards serves (everything except the Python files, brand/ and translations/ is build output and gitignored, so a fresh checkout has none of it until npm run build runs):

URLFromNotes
/lcards/lcards.js (+ .br, .gz)Vite entry src/lcards.jsLoader stub, under 2 KB (see Bundle and loading)
/lcards/chunks/*.js (+ .br, .gz, .map)Vite chunkslcards-main-<hash>.js plus every lazy chunk
/lcards/lcards.js.map, chunks/*.js.mapViteSource maps; left out of stable release zips
/lcards/fonts/, /lcards/sounds/, /lcards/msd/, /lcards/images/, /lcards/models/src/assets/<dir>/ copied by scripts/copy-assets.jsFonts, sound packs, ship blueprint SVGs, the image library, built-in GLB models
/lcards/brand/committedIntegration icons and logo
/lcards/THIRD_PARTY_NOTICES.txtscripts/generate-third-party-notices.jsLicence texts

Static paths in Home Assistant are served without authentication, so everything in both folders can be fetched by anyone who can reach the Home Assistant HTTP server (including the Python sources in the integration folder). The user folder is also public on /local/lcards/..., since it is inside <config>/www, whenever www existed at Home Assistant start. The user folder is outside custom_components/ on purpose: HACS replaces custom_components/lcards/ on every update, but never touches www/, so no persistent_directory is needed (const.py:12-23). It has its own path instead of /local/lcards because /local/ only exists if <config>/www existed when Home Assistant started. The /lcards-user path is not registered (and "My models" and "My fonts" are unavailable) when the models or fonts folder cannot be created; a warning is logged.


Bundle and Loading ​

The frontend is one Vite library build (vite.config.js), written straight into custom_components/lcards/ by vite build --mode integration (other modes write to the gitignored tmp/vite-build/; there is no dist/).

Loader stub. src/lcards.js (the Vite entry, about 30 lines) reads log and its own folder from its URL, stores them on window.__LCARDS_BOOT__, and dynamically imports ./lcards-main.js, which Vite emits as chunks/lcards-main-<hash>.js. src/lcards-main.js then applies the level (and the ?lcards_log_level= page URL override), registers every card element and initializes the core. The split exists because lazy chunks import shared code from the main chunk by its plain URL: if that code lived in the entry, they would request lcards.js without ?v=&log=, a second module URL, and the browser would run a second copy of the bundle (a second core).

Built-in asset URLs resolve against the bundle folder. The stub also records the folder it was loaded from as window.__LCARDS_BOOT__.base (the path, or a full URL when the bundle is on another origin; /lcards/ when its URL cannot be read). Packs, docs examples and configs write built-in asset URLs as /lcards/... (fonts, sounds, MSD SVGs, images, models, the brand icon); every place that fetches, links or plays one passes it through bundleUrl() (src/utils/bundle-url.js), which swaps the leading /lcards/ for that base. Other URLs (/lcards-user/..., /local/..., http(s)://, builtin: keys, data:) are untouched. In Home Assistant the base is /lcards/, so the URLs are identical; the versioned docs site serves the bundle from /dev/lcards/ or /v/<version>/lcards/, where a root-absolute /lcards/... would load the latest channel's copy. The font stylesheets in src/assets/fonts/ use url()s relative to their own folder for the same reason. tests/core/bundle-url.test.js fails on a literal /lcards/ URL in src/ that is used without bundleUrl(), and tests/browser/bundle-base.spec.js loads the bundle from /base-test/lcards/ and checks that no request goes to /lcards/.

Lazy chunks. Rarely needed code is split out with native import(), resolved relative to the importing chunk (no global chunk registry that could collide with other bundled cards). chunkFileNames: 'chunks/[name]-[hash].js'. The main ones:

Chunk(s)Loaded by
Card editors (lcards-*-editor-*.js, shared editor components)each card's static async getConfigElement() (await import('../editor/cards/...'))
Studio dialogs (for example lcards-alert-overlay-studio-dialog-*.js)their editors
Config panel (lcards-config-panel-*.js)lcards-config-panel is a light shell element in the main chunk (src/panels/lcards-config-panel-shell.js) that imports the real panel on first connect
Grid edit overlay (lcards-grid-edit-overlay-*.js)src/views/lcards-layout-view.js when dashboard edit mode starts
Theme generator (lcards-theme-generator-view-*.js)the theme token browser tab
Alert preview (lcards-alert-preview-*.js)window.lcards.loadAlertPreview() (docs demos, Alert Studio)
ApexCharts (apexcharts.esm-*.js)src/cards/lcards-chart.js when a chart renders, and the processor preview
three.js and WebGL scenes (three.module-*, three-runtime-*, warp-starfield-*, holo-sphere-*, nebula-*, ...)ThreeSceneEffect (src/core/packs/backgrounds/webgl/) for WebGL background presets
Astrometrics runtime and schema (scene-runtime, astrometrics-schema-*, ...)src/cards/lcards-astrometrics-card.js (import('../core/astrometrics/index.js'))

Minification and maps. esbuild minify with keepNames: true (logs and BaseService use constructor.name), plus a post pass that strips whitespace (minifyWhitespace plugin; Vite does not in library mode). Source maps map back to src/; with LCARDS_SOURCEMAP=hidden (stable releases) they are written but not referenced.

Pre-compression. The lcards-precompress plugin writes .br (quality 11) and .gz (level 9) next to lcards.js and every chunks/*.js. Home Assistant's static handler (aiohttp FileResponse) sends the compressed sibling when the browser accepts it. lcards-clean-chunks deletes chunks/ and the old lcards.js.br/.gz at build start (emptyOutDir is off because the Python files live in the same folder).

Why a hard refresh. /lcards is served with month-long cache headers. The stub URL changes only with DOMAIN_VERSION, but every build deletes the previous chunks, so after a rebuild with the same version a cached stub (or cached main chunk) points at chunk files that no longer exist (404). Hashed chunk names make everything else safe to cache. After npm run build during development, reload with Ctrl+Shift+R.

Size budget. tests/browser/bundle.spec.js (Layer A, after a build) checks that the stub is loaded once with its query and the main chunk once, that loading an editor reuses the same core, that rendering cards loads no editor code, and the budgets: lcards.js at most 2 KB, the main chunk at most 2,300,000 bytes raw and 500,000 bytes Brotli, three.js and the anime.js three adapter out of the main chunk, and the astrometrics runtime and schema in chunks of their own. Raise a ceiling only for a deliberate addition, with a dated comment as the test does.

Licence notices. scripts/generate-third-party-notices.js runs after the Vite build in npm run build, build:integration and docs:bundle, and writes custom_components/lcards/THIRD_PARTY_NOTICES.txt from the packages found in the build, so the release zip carries the licence texts. The release workflow fails without it. tests/docs/third-party.test.js keeps scripts/data/third-party.json in step with the imports in src/.


Media Source Platform ​

media_source.py exposes bundled assets and the user's own models as a browsable, read-only "LCARdS" folder in Home Assistant's media browser: the Media sidebar panel, media picker dialogs, and every ha-selector of type media (including the ones LCARdS editors use, see Asset Manager: media-source:// Resolution Flow).

Discovery is automatic. Home Assistant's media_source integration scans loaded integrations for a media_source.py with async_get_media_source(hass) (async_process_integration_platforms). manifest.json lists media_source under after_dependencies only to order setup.

Root (identifier prefix)FolderTitleLists files whose MIME type starts with
imagescustom_components/lcards/images/Imagesimage
soundscustom_components/lcards/sounds/Soundsaudio
msdcustom_components/lcards/msd/Ship Blueprintsimage
modelscustom_components/lcards/models/Modelsmodel
my_models<config>/www/lcards/models/My modelsmodel
my_fonts<config>/www/lcards/fonts/My fontsfont

(media_source.py, _ROOT_DIRS and _USER_ROOTS.) .glb, .gltf, .ttf, .otf, .woff and .woff2 get their model/* and font/* types by extension because not every Python's mimetypes table knows them; everything else uses mimetypes.guess_type. async_resolve_media() does not serve files: it returns a URL on one of the two static paths. Browsing and resolving run in the executor and resolve the requested path, then check it stays under its root (Path.relative_to()), the same traversal guard as Home Assistant core's local_source.py. The media source has no upload or delete: users copy their models into www/lcards/models/ themselves (File editor, Samba); fonts are added and deleted in LCARdS Config > Fonts (see Font Manager) or copied in the same way. The font picker reads My fonts (AssetManager.listInstalledUserFonts()) to mark the bring-your-own fonts a user has installed.


Config and Options Flow ​

config_flow.py. LCARdSConfigFlow.async_step_user() enforces one instance (async_set_unique_id(DOMAIN), and single_config_entry in the manifest) and creates the entry with no input. Options are edited under Settings > Devices & services > LCARdS > Configure (LCARdSOptionsFlow.async_step_init):

Option keyconst.py constantDefaultEffect
show_panelCONF_SHOW_PANELTrueRegister the sidebar panel or not
sidebar_titleCONF_SIDEBAR_TITLE"LCARdS Config"Sidebar label
sidebar_iconCONF_SIDEBAR_ICON"mdi:space-invaders"Sidebar icon
log_levelCONF_LOG_LEVEL"warn"Frontend and backend verbosity (off, error, warn, info, debug, trace), see Logging
enable_previewsCONF_ENABLE_PREVIEWSFalsePreview features in the frontend; read from lcards/info options (for example integrationService.options.enable_previews in the sound tab)

Saving reloads the entry (unload, then setup), so every option applies without a restart. lcards/info returns the current values with defaults filled in.


WebSocket API ​

async_setup_ws() (websocket_api.py:123-164) registers 30 commands in async_setup(). Each handler is @websocket_api.async_response; schemas use probatio (imported as vol, the voluptuous successor Home Assistant uses since 2026.10). Two error codes are LCARdS's own: unauthorized ("Admin access required", from _require_admin()) and storage_unavailable ("LCARdS storage is not initialised", from _check_storage(), before async_setup_entry has run). Admin checks always run before the storage check.

CommandAuthHandler (websocket_api.py)Request fieldsResult
lcards/infoany userws_lcards_info (:167-217)none{ available, version, storage_key_count, options, capabilities }
lcards/diagnosticsadminws_lcards_diagnostics (:220-238)noneasync_collect_backend_diagnostics() (see Support and diagnostics)
lcards/subscribeany userws_subscribe (:407-436)noneempty result, then one event message per lcards_event
lcards/fire_eventadmin; non-admin: own-user reload_connection_config onlyws_fire_event (:467-510)action, target_device_ids?, target_user_ids?, data?empty result
lcards/storage/getany user for plain (global) keys; a _device_* key as device/get; admin for the full store (no key) and _user_* keysws_storage_get (:245-274)key?{ key, value }
lcards/storage/setadminws_storage_set (:277-300)data{ ok, keys }
lcards/storage/deleteadminws_storage_delete (:303-325)key{ ok, existed }
lcards/storage/delete_manyadminws_storage_delete_many (:328-351)keys{ ok, removed } (count)
lcards/storage/get_manyany user; _user_* and _device_* keys read as nullws_storage_get_manykeys{ values }
lcards/storage/resetadminws_storage_reset (:354-375)none{ ok }
lcards/storage/dumpadminws_storage_dump (:378-400)none{ version, data }
lcards/storage/user/getany user (own record)ws_storage_user_get (:518-545)key?{ user_id, key, value }
lcards/storage/user/setany user (own record)ws_storage_user_set (:548-574)data, replace?{ ok, user_id, keys }
lcards/storage/user/deleteany user (own record)ws_storage_user_delete (:577-600)key{ ok, user_id, existed }
lcards/storage/users/listadminws_storage_users_list (:607-633)none{ users: { <id>: { key_count } } }
lcards/storage/users/getadminws_storage_users_get (:636-661)user_id{ user_id, value }
lcards/storage/users/setadminws_storage_users_set (:664-693)user_id, data, replace?{ ok, user_id, keys }
lcards/storage/users/clearadminws_storage_users_clear (:783-807)user_id{ ok, removed, user_id }
lcards/storage/device/getadmin, or the record's current owner (a record with no owner: any user)ws_storage_device_get (:704-735)device_id, key?{ device_id, key, value }
lcards/storage/device/setany user (a non-admin becomes the owner; an admin claims only an unowned record)ws_storage_device_set (:738-776)device_id, data, replace?{ ok, device_id, keys } (without owner_user_id)
lcards/storage/devices/listadminws_storage_devices_list (:840-874)none{ devices: { <id>: { display_name, last_seen, user_agent, owner_user_id, key_count } } }
lcards/storage/devices/getadminws_storage_devices_get (:877-902)device_id{ device_id, value }
lcards/storage/devices/setadmin (data.owner_user_id sets the owner)ws_storage_devices_set (:905-934)device_id, data, replace?{ ok, device_id, keys }
lcards/palette/getany user (only the cleaned palette)ws_palette_getdevice_name{ device_name, palette, last_seen } (see Kiosk Satellite Bridge)
lcards/storage/devices/clearadminws_storage_devices_clear (:810-834)device_id{ ok, removed, device_id }
lcards/fonts/getany userws_fonts_getnone{ record, files: { <name>: { size, mtime } }, css_url }
lcards/fonts/scanadminws_fonts_scannone{ record, files: [ { file, size, mtime, kind, valid, native, family, subfamily, weight, style, error?, used_by } ], missing, max_bytes }
lcards/fonts/saveadminws_fonts_savefonts{ record }; bad_record with the reason
lcards/fonts/deleteadminws_fonts_deletefile, force?{ ok, file, used_by, revision }; invalid_file, not_found, in_use (without force)
lcards/fonts/nativeany userws_fonts_nativenone{ revision, fonts: [ { key, name, group, faces: [ { url, weight, style } ], size_adjust } ] }: the fonts an Android app can draw (TTF/OTF), resolved like the stylesheet; for the LCARdS Voice Skin's Font setting (fonts.native_fonts())

The user commands always take the user ID from connection.user.id, never from the request. A device ID is a routing key the browser chooses (a UUID in localStorage), not a credential. What each storage command does to the store, and the replace semantics, are in Persistent Storage; the client wrapper is Scoped Settings; call examples are in Backend API.

lcards/info ​

The backend probe. IntegrationService sends it on the first HASS update with a connection, retries after 1, 3 and 8 seconds, and settles into degraded mode only when all four attempts fail (see Integration Service: Lifecycle). It asks again after every reconnect, and for 10 minutes after a degraded start, until the integration answers (Integration Service: Reconnects).

FieldValue
availablealways true (a failed or missing command is how "not available" shows)
versionDOMAIN_VERSION, the full version with any -dev.N suffix
storage_key_countnumber of top-level keys in the store (scoped records included), or null before async_setup_entry
optionsthe five options with defaults filled in, or null when there is no config entry
capabilities["scoped_storage", "scoped_storage_replace", "own_user_reload", "storage_get_many", "kiosk_palette", "fonts", "fonts_native"]
CapabilityMeaning
scoped_storageThe storage/user/*, users/*, device/* and devices/* commands exist
scoped_storage_replaceThe four scoped set commands accept replace: true; ScopedSettingsService.write() sends it only when this is advertised
storage_get_manylcards/storage/get_many reads several global keys in one call; IntegrationService.readStorageMany() falls back to one storage/get per key without it. ScopedSettingsService.readMany() uses it to read the connection overlay's settings in one call per scope (2026-11-18)
own_user_reloadA non-admin may send reload_connection_config to their own sessions through lcards/fire_event
fontsThe font manager: lcards/fonts/*, /api/lcards/fonts.css and the upload view
fonts_nativelcards/fonts/native, the font list for native apps

Capabilities let a newer frontend run against an older backend: the frontend checks for a capability before using the feature (Integration Service: capabilities).

lcards/subscribe ​

ws_subscribe listens on the Home Assistant event bus for lcards_event and forwards each event's data dict as an event message on the subscription (websocket_api.event_message(msg["id"], event.data)). The bus listener's unsubscribe function goes into connection.subscriptions[msg["id"]], so Home Assistant removes it when the client unsubscribes or the WebSocket closes. It exists because Home Assistant's own subscribe_events is admin-only for custom event types; this one is open to every user. See Python to JS Push Channel.

lcards/fire_event ​

Relays an event from one browser to every subscribed browser: it fires lcards_event with { action, ...data } plus target_device_ids / target_user_ids when given. Admin only, because the event can act on other users' sessions. The single non-admin exception (_own_user_event_allowed(), websocket_api.py:450-464, capability own_user_reload) requires all of:

  • action is reload_connection_config;
  • target_user_ids is exactly [<caller's user id>];
  • no target_device_ids (a device ID is not tied to a user);
  • data has only origin_device_id, with string values (data is spread into the payload, so any other key could widen the targets).

ConnectionOverlayService.saveConfig() uses it after an own-user save, and the connectivity tab sends reload_connection_config and reload broadcasts (admin). See Connection Overlay: Remote Config Sync. Layer C tests: tests/ha/ha.spec.js "a non-admin may relay reload_connection_config to their own sessions only".

Storage commands ​

Global (storage/*) and scoped (storage/user/*, users/*, device/*, devices/*) commands are in the table above. Since 2026-11 (D3a) every global write, the full read and dump are admin-only, and storage/get refuses non-admins for _user_* keys; non-admins keep their own user record and device records. Layer C: "global storage is admin-only; a non-admin keeps their own user and device storage" and "storage/delete_many removes the given keys with one call and leaves the rest" in tests/ha/ha.spec.js. Details: Persistent Storage.

Font Manager ​

The fonts the user adds (LCARdS Config > Fonts) live in two places: the files in <config>/www/lcards/fonts/ (served without login at /lcards-user/fonts/, no cache headers), and the fonts record in LCARdS storage under the key fonts, which says which file is which font:

json
{ "version": 1, "revision": 7, "fonts": {
    "lcards_tungsten": { "aliases": ["Tungsten"],
      "faces": [{ "file": "Tungsten-Medium.woff2", "weight": 400, "style": "normal" }],
      "metrics": { "size_adjust": 120, "ascent": 96, "descent": 12.5 } },
    "lcards_user_okuda": { "name": "Okuda", "aliases": [],
      "faces": [{ "file": "Okuda.otf", "weight": 400, "style": "normal" }] } } }
  • Keys: a bring-your-own key from fonts/fonts.json (read once by font_store.async_manifest()), or lcards_user_<slug> (fonts.slug_key(), made once by the Fonts tab, never changed).
  • Stand-ins: a user font's stands_in_for lists bring-your-own keys it also draws ("stands_in_for": ["lcards_swiss_911"]): the stylesheet declares each with that font's files and metrics. A bring-your-own key has one stand-in at most, and none while it has files of its own.
  • Checks (fonts.clean_record(), mirrored in src/utils/font-settings.js for the tab): bare file names inside the folder; weight 1 to 1000 and normal/italic, one file per weight and style; aliases of 1 to 40 letters, digits, spaces and hyphens, not lcards_*, not a CSS keyword, not a font LCARdS includes (reserved_family_names()), unique; metrics (size_adjust 50 to 200, ascent, descent, line_gap 0 to 150, percent). A record of another version, or one changed by hand that fails the checks, reads as empty (read_record()).
  • The stylesheet GET /api/lcards/fonts.css (FontsCssView, no login like the font files themselves) is made from the record and the folder on each request (fonts.fonts_css()): an @font-face per face, under the key and under each alias, with the metrics as size-adjust / ascent-override / descent-override / line-gap-override, and ?m=<mtime> on the file URL so a replaced file is fetched again. A face whose file is gone is left out; a user font with no file left is declared as Antonio, so it never falls to the browser default; a bring-your-own key with none keeps its built-in CSS. Cache-Control: no-cache and an ETag (SHA-256 of the CSS): browsers check on each load and get a 304 when nothing changed.
  • Upload POST /api/lcards/fonts/upload (FontUploadView, admin, else 403 not_admin): multipart field file, ?overwrite=1 to replace. The name goes through safe_file_name() (base name, [A-Za-z0-9 ._-], at most 100 characters, .ttf .otf .woff .woff2); the body is read up to 10 MB (MAX_FONT_BYTES, 413 too_large beyond), checked by its first bytes (not_a_font, collection for .ttc) and written to a temporary file in the folder, then renamed into place. 409 exists without overwrite. Returns the file's describe_file() info.
  • Metadata (read_font_meta()): family and subfamily from the name table (IDs 16/17, else 1/2), weight from OS/2.usWeightClass, italic from OS/2.fsSelection or head.macStyle. WOFF needs only zlib; WOFF2 needs the brotli module, which Home Assistant installs (package_constraints.txt); without it the values are null. Results are cached per file name, size and mtime.
  • Changes (save, upload, delete) bump revision and fire lcards_event {action: fonts_changed, revision} to every dashboard.
  • Diagnostics (support.py) list which keys use which files, the folder's file names and sizes, and missing files.

Layer C: tests/ha/fonts.spec.js. The rules in node: tests/support/fonts.test.js.


Logging ​

All Python files use logging.getLogger(__name__) under custom_components.lcards.

The log_level option controls both sides:

  • Frontend: frontend.py appends &log=<level> to the injected URL; the loader stub reads it from import.meta.url before it imports the main chunk, and src/lcards-main.js applies it before the banner. Static imports are hoisted, so the modules lcards-main.js imports are evaluated first: their few module-level logs use the level saved in localStorage (else info); everything after that, core init included, uses the new level. The page URL parameter ?lcards_log_level= overrides it for that page load.
  • Backend: async_setup_entry() maps the level through _LOG_LEVEL_MAP (const.py:54-61) and calls setLevel() on custom_components.lcards.
LCARdS levelPython level
offCRITICAL + 1 (silent, without touching logging.disable())
errorERROR
warnWARNING
infoINFO
debugDEBUG
traceDEBUG (Python has no TRACE)

The lcards.set_log_level action changes both at runtime without saving the option: the Python level (process-wide, even for a targeted call; a target that matches nobody fails the call and leaves it unchanged) until the next entry reload, and the browsers it reaches until their next page load. Home Assistant's logger: configuration can also set custom_components.lcards directly.


Home Assistant Services (Actions) ​

async_setup_services() (services.py:255-696) registers 18 actions in async_setup_entry(); async_remove_services() removes the names in _ALL_SERVICES on unload. Field schemas use probatio.

ActionFields (besides targeting)Without targetingWith targeting
lcards.set_alert_modemode (one of the six alert modes)input_select.select_option on input_select.lcards_alert_modelcards_event set_alert_mode
lcards.red_alert, yellow_alert, blue_alert, gray_alert, black_alertnonesets that mode on the helperset_alert_mode event
lcards.clear_alertnonesets green_alert on the helperset_alert_mode event with green_alert
lcards.reloadnonelcards_event reload to allsame, targeted
lcards.set_log_levellevelPython level plus set_log_level eventsame, event targeted
lcards.trigger_effectlayers, duration? (ms, at least 100)trigger_effect eventsame, targeted
lcards.clear_effectslot? (backdrop, canvas, color; empty = all)clear_effect eventsame, targeted
lcards.play_soundevent_type or asset_key (one is required)play_sound eventsame, targeted
lcards.fly_tocard_id, view or point, duration?, warp?fly_to eventsame, targeted
lcards.set_clockcard_id, date and/or rateset_clock eventsame, targeted
lcards.show_portal_cardcontent, layers?, position?, width?, height?, duration?, dismiss?show_portal_card eventsame, targeted
lcards.clear_portal_cardnoneclear_portal_card eventsame, targeted
lcards.borg_assimilateintro_duration?, transition_style?, site_count?, tendrils_per_site?, tendril_length?, particle_count?, renderer?, cube?, corruption?, overrun?, suppress_persistent?, font_swap?, palette_hue? (0-359), sound?, intro_layers?, persistent_layers?borg_assimilate eventsame, targeted
lcards.borg_deassimilatewith_outro?, outro_layers?, revert_transition_style?, sound?borg_deassimilate eventsame, targeted

Per-field validation, the payload each handler builds and every error are in Home Assistant Services: Implementation Notes. The user reference with examples is Home Assistant Actions.

Targeting (all services) ​

Every action accepts four optional list fields, resolved in _async_resolve_targets() (services.py:105-168) and combinable:

FieldResolves to
target_device_idsBrowser device UUIDs (the lcards_device_id localStorage key), used as given
target_device_namesDevice display names (config panel or ?lcards_device=), matched case-insensitively against display_name in the _device_* storage records; a name shared by several devices hits all of them
target_user_idsHome Assistant user IDs, used as given
target_user_namesHome Assistant user names, matched case-insensitively against hass.auth.async_get_users()
  • No targeting fields: a broadcast (or, for the alert actions, the shared helper write).
  • Targeting that resolves to at least one ID: the event carries target_device_ids / target_user_ids and each browser keeps only events addressed to it (union of both lists).
  • Targeting that matches nobody (for example a misspelt name): ServiceValidationError ("LCARdS: no device or user matches the target (names: [...])"). It never falls back to a broadcast.

The alert actions write input_select.lcards_alert_mode only without targeting: that helper is the shared alert state, and the browsers follow it through their HelperManager subscriptions. A targeted alert is a transient, local change on the matched browsers (setAlertMode(mode, { skipHelperSync: true })). Without targeting and without the helper, the call fails with ServiceValidationError telling the user to create the LCARdS helpers. How a browser then applies the mode: Theme System: Alert Mode Integration.


Python to JS Push Channel ​

Eleven actions (reload, set_log_level, trigger_effect, clear_effect, play_sound, fly_to, set_clock, show_portal_card, clear_portal_card, borg_assimilate, borg_deassimilate) always reach the browsers through _fire_targeted_event() (services.py:171-188). The seven alert actions use it only when targeting is given. lcards/fire_event puts browser-originated events on the same channel. A device write that changes a stored palette fires palette_changed (device_name) on it too, for native Kiosk Satellite apps; dashboards ignore it (Kiosk Satellite Bridge).

Transport is always a broadcast to every subscription; the targeting is enforced in the browser. Payloads leave the target keys out when they are empty.

actionFired byExtra payload fields
reloadlcards.reload, connectivity tab (lcards/fire_event)none
set_log_levellcards.set_log_levellevel
set_alert_modetargeted alert actionsmode
trigger_effectlcards.trigger_effectlayers, duration?
clear_effectlcards.clear_effectslot? (left out for all slots)
play_soundlcards.play_soundevent_type or asset_key
fly_tolcards.fly_tocard_id, view?, point?, duration?, warp?
set_clocklcards.set_clockcard_id, date?, rate?
show_portal_cardlcards.show_portal_cardcontent, layers, position, width, height, duration, dismiss (always all keys; null when not given)
clear_portal_cardlcards.clear_portal_cardnone
borg_assimilatelcards.borg_assimilatenormalised options: intro_duration, transition_style, intro_layers, persistent_layers, fontSwap, paletteHue, sound
borg_deassimilatelcards.borg_deassimilatewith_outro, outro_layers, revert_transition_style, sound
reload_connection_configlcards/fire_event only (ConnectionOverlayService, connectivity tab)origin_device_id?

What each browser does with each action is the Integration Service: Handled actions table.

Subscription lifecycle ​

Browser                                      Home Assistant
-------                                      --------------
first HASS update with a connection
  IntegrationService.updateHass()
    initialize() ----- lcards/info --------> ws_lcards_info()
    <------------------ { available, ... } --
    _startEventListener()
      subscribeMessage(cb) - lcards/subscribe -> ws_subscribe():
                                                 hass.bus.async_listen("lcards_event", _forward)
                                                 connection.subscriptions[id] = unsub
      _eventUnsubscribe = unsub fn

lcards_event fired (action or fire_event)
    <------------- event_message(id, data) -- _forward(event)
    _handleLcardsEvent(data)

WebSocket closes (tab closed, page reload, connection lost)
                                             Home Assistant calls every
                                             connection.subscriptions[...] unsub

The probe and the first subscription happen once per page load (the _probed and _eventUnsubscribe guards in src/core/services/IntegrationService.js). After a lost connection (a Home Assistant restart, for example) IntegrationService subscribes again itself on the connection's ready event, retrying until lcards/info answers: the page often reconnects before the integration has registered its commands, and home-assistant-js-websocket's own resubscribe tries once and drops a failure (#426), so the subscription is made with { resubscribe: false }. Unloading the config entry does not touch existing subscriptions: ws_subscribe is registered in async_setup() and stays.


Support and Diagnostics ​

One collector, two consumers: async_collect_backend_diagnostics(hass) in support.py serves both the lcards/diagnostics WebSocket command (admin) and Home Assistant's Download diagnostics for the config entry (diagnostics.py, async_get_config_entry_diagnostics; Home Assistant adds its own system information to that file). It reports environment facts only; stored data is reported as counts, never contents.

FieldContent
versionsintegration (DOMAIN_VERSION), home_assistant, min_home_assistant ("2026.11")
safe_mode, recovery_modefrom hass.config
resourcesLovelace resource mode, and only the LCARdS and card-mod entries (url, type, legacy), lcards_count, legacy_lcards (an entry on the old /hacsfiles/lcards/ or /local/community/lcards/ path), card_mod
extra_module_urlsfrontend: extra_module_url entries, minus LCARdS's own URL
card_mod_in_extra_module_urlwhether one of those is card-mod
componentswhether uix, hacs and card_mod are loaded
config_entrypresent, options
storageschema_version, key_count

Welcome tab health check. The config panel's Welcome tab (src/panels/components/lcards-about-tab.js, Support and system info section) calls buildSupportReport() (src/utils/support-info.js). collectSupportInfo() waits for the lcards/info probe, gathers browser-side facts (versions, capabilities, options, theme, UIX and card-mod detection, recent log entries) and, for admins, the lcards/diagnostics result; a non-admin, or an unauthorized reply, gives backend.status: 'admin_required'. evaluateSupportChecks() (src/utils/support-info-format.js) turns that into checks:

Check idUses the backend facts?Flags
ha_versionno (hass.config.version)Home Assistant older than 2026.11 (error)
integration / version_matchno (lcards/info)integration not responding (error); frontend and integration versions differ (warn: hard refresh)
safe_modesafe_mode, recovery_modesafe or recovery mode (warn)
stylingcomponents, resources.card_mod, card_mod_in_extra_module_urlUIX and card-mod together (error), card-mod (warn), HA-LCARS without UIX (warn)
extra_module_urlextra_module_urlscard-mod left in extra_module_url (warn)
layout_cardresources.entriescustom:layout-card installed (info)
resourcesresourcesa legacy LCARdS resource, or more than one LCARdS resource (warn)
backendstatusbackend checks skipped (needs an admin) or unavailable (info)
ha_lcarsnoHA-LCARS theme active or not (info)

The tab can copy the report as Markdown or open a prefilled GitHub issue (openIssueForReport()); the console has the same through window.lcards.support.collect/report/copy/openIssue (src/lcards-main.js:142-147). The user-facing side is described in Troubleshooting.


Build and Dev Workflow ​

Use npm run build for every build, development included. It runs the validators first (doc examples, schema descriptions, em dashes, "Home Assistant" naming, CSS variables, Home Assistant compatibility lint, tsc), then scripts/set-version.js (copies package.json's version into manifest.json as Home Assistant CalVer and into const.py in full), vite build --mode integration, scripts/copy-assets.js and scripts/generate-third-party-notices.js. npm run build:integration is the last three steps only, for CI and the release workflow.

Output in custom_components/lcards/:

lcards.js, lcards.js.br, lcards.js.gz, lcards.js.map   loader stub
chunks/*.js (+ .br, .gz, .map)                         main chunk and lazy chunks
fonts/ msd/ sounds/ images/ models/                    from src/assets/ (copy-assets.js)
THIRD_PARTY_NOTICES.txt                                licence notices

In the devcontainer custom_components/lcards/ is bind-mounted into Home Assistant, so a build is live after a hard refresh (Ctrl+Shift+R, see Bundle and loading). Python changes need a Home Assistant restart. The maintainer runbook for every script and workflow is COOKBOOK.md in the repository root.


CI and Release Pipeline ​

.github/workflows/validate-integration.yml runs on pushes and pull requests to main, dev and develop, nightly, and as the release gate: the CSS variable validator, the strict doc-example validator, the schema description and em-dash checks, npm test, npm run typecheck, npm run test:browser on a build:integration bundle, and a plain build. .github/workflows/release.yml is started by hand (workflow_dispatch): main gives a stable release, any other branch a pre-release (overridable).

  1. Runs the validate workflow first.
  2. Reads the version from package.json and exports the release notes from doc/releases/<version>.md (scripts/release-notes.mjs export) as the release body, with links to the schema and skill assets. A stable release fails without the page or while it is still status: testing; a pre-release without a page gets GitHub's generated notes only. This runs before tagging, so a failed check leaves no tag.
  3. Creates and pushes the tag if it does not exist.
  4. Stamps the version: manifest.json gets Home Assistant CalVer (suffix stripped, no leading zero in the month), const.py the full string.
  5. npm run build:integration with LCARDS_SOURCEMAP=hidden for stable releases (maps written, not referenced) and linked maps for pre-releases, then checks the output: lcards.js and its .br/.gz, compressed chunks, the main chunk, THIRD_PARTY_NOTICES.txt, and the fonts, msd and sounds folders.
  6. Zips custom_components/lcards/ as lcards.zip (without __pycache__, *.pyc, and for stable releases without *.map; it fails if a stable zip holds a map or a stable file still points at one).
  7. Builds lcards-schema.json, lcards-schema.zip, lcards-validate.mjs, lcards-skill.zip and lcards-plugin.zip, and creates the GitHub release with all six files. The unpacked plugin in plugins/lcards/ (the repo-root marketplace that claude.ai reads from main) is not built here: the release steps rebuild it after the stable bump (npm run plugin:tree), so it arrives on main with the release pull request.
  8. For a stable release, archives that version's docs (docs.yml, /v/<version>/).

HACS downloads lcards.zip and unpacks it into custom_components/lcards/.

Released under the MIT License. | About