Systems Architecture
How the pieces fit at runtime: the Python integration, the one JavaScript bundle it loads into every Home Assistant page, the core singletons on
window.lcards.core, and the cards, view and strategy on a dashboard.
Runtime overview
- Loading.
frontend.pyserves the integration folder at/lcardsand registers/lcards/lcards.jswithadd_extra_js_url(), so the bundle loads on every Home Assistant page without a Lovelace resource.lcards.jsis a small loader stub that imports the hashed main chunk (chunks/lcards-main-*.js); editors, studios, the config panel, the grid edit overlay, ApexCharts and three.js are lazy chunks. See Home Assistant Integration: Bundle and Loading. - Core start.
src/lcards-main.jscallslcardsCore.initialize(stubHass)when the main chunk runs and defines the card elements only after it resolves; the view element and the strategy element are defined at module top level (Home Assistant's strategy resolver waits only a short time). The 30 initialization steps are listed in Core Subsystems: Initialization Order. - HASS. Home Assistant sets
hasson each card. AnLCARdSCardforwards it towindow.lcards.core.ingestHass()only on its first HASS or when one of its own entities changed; the core then pushes it to its services once per microtask. While no card is registered (or a portal overlay shows content) the core pollsdocument.querySelector('home-assistant').hassevery 500 ms instead. See HASS distribution and Card Foundation: HASS flow. - Rules listen to their entities' state changes themselves, through the one subscription the page shares with helpers and data sources (
src/core/state-change-hub.js, asubscribe_entitiesfiltered to the entities they name), so rule entities update even when no card forwarded the change (Rules Engine). - Backend channel.
integrationServiceprobeslcards/infoon the first HASS with a connection, then subscribes to thelcards_eventpush channel throughlcards/subscribe(Home Assistant's ownsubscribe_eventsis admin-only for custom event types). Thelcards.*actions (alert mode, reload, screen effects, sound, Borg, astrometrics) reach the browsers this way. See Integration Service and Home Assistant Services: Implementation Notes. - Actions. Each card has its own
LCARdSActionHandler(there is no core action handler); service calls go throughLCARdSCard.callService()(Action Handler).
What runs where
| Element | Class (file under src/) | Base | Architecture page |
|---|---|---|---|
lcards-button, lcards-elbow, lcards-slider | LCARdSButton, LCARdSElbow, LCARdSSlider (cards/) | LCARdSCard (elbow and slider extend the button) | Card Foundation |
lcards-chart | LCARdSChart (cards/lcards-chart.js, charts/) | LCARdSCard | Charts |
lcards-data-grid | LCARdSDataGrid (cards/lcards-data-grid.js, data-grid/) | LCARdSCard | Card Foundation |
lcards-select-menu | LCARdSSelectMenu (cards/lcards-select-menu.js) | LCARdSCard | Card Foundation |
lcards-astrometrics-card | LCARdSAstrometricsCard (cards/lcards-astrometrics-card.js, core/astrometrics/) | LCARdSCard | Astrometrics |
lcards-msd-card | LCARdSMSDCard (cards/lcards-msd.js, msd/) | LCARdSCard | MSD Pipeline |
lcards-layout-card | LCARdSLayoutCard (cards/lcards-layout-card.js) | LitElement | Layout View and Layout Card |
lcards-alert-overlay | LCARdSAlertOverlay (cards/lcards-alert-overlay.js) | LitElement | Screen Effects, Portal Overlay Manager |
lcards-layout-view (view type custom:lcards-layout-view) | LCARdSLayoutView (views/lcards-layout-view.js) | LitElement | Layout View and Layout Card |
ll-strategy-dashboard-lcars-shell (strategy custom:lcars-shell) | LCARdSShellDashboardStrategy (strategies/lcards-shell-strategy.js) | HTMLElement | Shell Strategy |
All elements are registered in src/lcards-main.js, each behind a customElements.get() guard. The card picker entries are one guarded push of LCARdSCardClasses into window.customCards; the strategy is listed in window.customStrategies for Home Assistant's New Dashboard picker.
Core services
window.lcards.core is the LCARdSCore instance (src/core/lcards-core.js). It creates these services once and exposes each as a property. Each one is documented in Core Subsystems, which also has the full initialization table.
| Area | Services (window.lcards.core.*) |
|---|---|
| Entities and overlays | systemsManager (entity cache, subscriptions, card and overlay registries) |
| Data | dataSourceManager (named buffers with processors) |
| Rules | rulesManager (one engine for every rule on the page) |
| Theming | themeManager (tokens, alert modes), stylePresetManager, componentManager |
| Animation | animationManager, performanceMonitor (FPS watch for canvas backgrounds) |
| Config | validationService, configManager (merge pipeline with provenance) |
| Assets and packs | assetManager, packManager |
| Helpers and sound | helperManager (LCARdS input_* helpers, alert-mode auto-switch), soundManager |
| Screen | screenEffectManager, borgAssimilationManager, portalOverlayManager, connectionOverlayService |
| Backend | integrationService, deviceIdentityManager, scopedSettingsService |
The template evaluator is not a singleton: UnifiedTemplateEvaluator is created per use (Template System). There is no actionHandler and no animationRegistry on the core: action handlers are per card, and the animation presets are a module registry (src/core/animation/presets.js).
Packs
Packs are plain JavaScript objects bundled with LCARdS that fill the registries at startup. There is no external or user pack loader.
PackManager.loadBuiltinPacks()(src/core/PackManager.js) is called once, fromLCARdSCore._performInitialization(), withCORE_REQUESTED_PACK_IDS;loadBuiltinPacks()(src/core/packs/loadBuiltinPacks.js) adds the always-loaded packs, so 14 packs are registered.- Animation presets do not come from packs:
registerBuiltinAnimationPresets()fills the preset registry insrc/core/animation/presets.js. - The
ruleskey is supported, but no built-in pack ships rules today.
What each pack holds and how to add one: Pack System.