MSD Rendering Pipeline
Internal architecture of the
lcards-msd-card: how config becomes a rendered Master Systems Display.
Overview
The MSD card has a dedicated rendering pipeline in src/msd/. It composes a base SVG with any number of positioned overlays (embedded cards, routed lines, shapes), routes SVG lines between them, and applies per-overlay animations and rules. The card element itself (LCARdSMSDCard, src/cards/lcards-msd.js) extends LCARdSCard like every other card; the pipeline is what it adds on top.
Non-MSD cards use LCARdSCard directly; the MSD pipeline is purposely isolated. The rules for working in src/msd/ (overlay types, z-order, animations, Studio conventions, anti-patterns) live in .claude/rules/msd.md; this page explains how the pieces fit, and why.
The entry point is initMsdPipeline() (src/msd/pipeline/PipelineCore.js:34, re-exported by src/msd/index.js). It returns the pipeline API object the card stores on this._msdPipeline.
Pipeline Stages
What happens between setConfig() and a visible MSD, in call order:
Step by step, with the code that does it:
- Card config processing.
LCARdSCard.setConfig()runs the card config (withmsd:nested inside it) throughCoreConfigManager.processConfig()like every card._onConfigUpdated()(lcards-msd.js:265) storesthis._msdConfig = config.msdandthis._fullConfig = config; aview_boxwith nobase_svg.sourcebecomessource: nonehere. On a livesetConfig()of an already running pipeline it also calls_reconcileViewBoxIfChanged()(:323), which pushes a changed view box intocardModelandrouter.setViewBox()and re-renders. - Load.
_loadAndInitializeMsd()(:398, a dedup wrapper so the first-mount and reconnect entry points never run twice at once) awaits config processing, loads the SVG throughAssetManager(_loadBaseSvg(),:1089;media-source://sources take the async resolve path), and picks the instance GUID (msd-<config.id>ormsd-<cardGuid>). Card picker and editor-dialog previews (_isPreviewModepicker/editor) skip the pipeline entirely and render a placeholder. - Mount the SVG.
_initializeMsdPipeline()(:1152) sets_msdInitialized = trueso_renderCard()switches from the loading spinner to_renderSvgContainer(), awaitsupdateComplete, and checks that an<svg>exists in the render root. The container stays at opacity 0 until the reveal in step 9. - Config processing and anchors (
processAndValidateConfig(),src/msd/pipeline/ConfigProcessor.js:24). Resolves the effective view box (explicitview_box> the SVG's own > default), computes landmark anchors withSvgStructureAnalyzer(unlessbase_svg.harvest_landmarks: false), harvests SVG element anchors withAnchorProcessor(unlessbase_svg.harvest_svg_elements: false), runs the config throughCoreConfigManager.processConfig(config, 'msd')again, flattens the result to themsdobject (mergedConfig), resolves percentage coordinates in anchors and in overlayposition/anchor/attach_to, and checks every string anchor reference. A missing or self-referencing anchor is an error (anchor.missing,anchor.self_reference); any error returns a disabled pipeline (createDisabledPipeline(),PipelineCore.js:466) withenabled: false. - Coordinator, phase one (
initializeSystemsWithPacksFirst(),MsdCardCoordinator.js:87). Takes the shared coreThemeManager,StylePresetManagerandDataSourceManager(the MSD creates no data sources of its own: card-rootdata_sourcesare created byLCARdSCard._processDataSourcesConfig(), and the core feeds the manager HASS).PipelineCorethen points the coreCoreValidationServiceat the theme and data source managers. - Card model (
buildCardModel(),src/msd/model/CardModel.js:16). Builds{ viewBox, baseSvg: { source, filters, animations }, anchors, overlaysBase, animations, __raw }.overlaysBaseholds one normalized entry per overlay (id,type,style,raw, plus the position, size and line keys it copies); a line'sanchorbecomes itspositionhere. - Coordinator, phase two (
completeSystems(),MsdCardCoordinator.js:151). Creates oneRouterCoreper card (config{ ...msd.routing, channels: msd.channels }, the card model's anchors and view box), theAdvancedRendererand theMsdControlsRenderer, and takes the shared coreAnimationManager. - Animations, HASS, first render.
AnimationManager.initialize(overlays)only registers animation definitions per overlay id; it runs beforeModelBuilderexists and long before any DOM.coordinator.ingestHass()pushes the first HASS.new ModelBuilder()is stored ascoordinator.modelBuilder,reRender()is handed to the coordinator (setReRenderCallback) and run once. After it:applyBaseSvgFilters()on#__msd-base-content, and thebase_svg.animationsscope (__msd_base_svg:<guid>) is registered once, since the base SVG group never changes after the first parse. - Card wiring. Back in the card:
setCardInstance(this)(actions and state colours reach the card throughcoordinator.cardInstance),_registerOverlaysWithRulesEngine()(:547), an await of the rules re-render that registration may start,_processCustomTemplates()(pre-evaluates Jinja2/JavaScript templates in overlay styles), then thebackground_animationlayer and the reveal (_msdRevealed = true).
In MSD Studio's live preview (isEditMode, the card's _isStudioPreview) the pipeline skips every animation registration and the background animation: that preview card is destroyed and rebuilt on every edit and every HASS tick (lcards-msd-live-preview.js), so starting them is wasted work.
Each render (reRender())
reRender() (PipelineCore.js:211) is the full structural render. It is serialized: a call while one is running sets coordinator._queuedReRender and returns { success: false, reason: 'render_in_progress', queued: true }; the queued render runs 50 ms after the running one finishes.
ModelBuilder.computeResolvedModel()(ModelBuilder.js:21) builds each overlay fromoverlaysBase({ ...raw, ...base, style, finalStyle, _raw },theme:tokens instyleresolved through the component-scopedThemeManager.resolver), hands the overlays torouter.setOverlays(), and returns{ viewBox, anchors, overlays, animations, config }(animationsis always empty: overlay animations are read from each overlay's ownanimationslist).AdvancedRenderer.render(resolvedModel)draws everything (next section).cardInstance._onMsdRendered()re-applies the last style-only rule patches to the fresh DOM.- For every overlay with registered animations,
AnimationManager.onOverlayRendered(id, element, overlay, coordinator), whereelementis[data-overlay-id="<id>"]. Then the card-levelmsd.animationsscope (__msd_animations:<guid>) on#msd-overlay-container; it re-registers every render because that group's children are rebuilt.
Inside AdvancedRenderer.render()
src/msd/renderer/AdvancedRenderer.js:85:
- Finds the
<svg>in the mount element, gets or creates<g id="msd-overlay-container">, empties it (innerHTML = '') and clearsoverlayElementCache. - Pass 2a, everything but lines, awaited one by one so each control's attachment points exist before any line routes. Controls whose
positionnames another control render after the independent ones (one level of dependency). Shapes render throughShapeOverlayand register their attachment points right after (bbox points plus kebab-case corner aliases, or<id>.vertex<N>per polyline vertex). Controls go toMsdControlsRenderer.renderControlOverlay(). - Waits two animation frames for embedded cards to settle, then builds virtual anchors from every overlay's attachment points and the static anchors.
- Route discovery (
_discoverLineRoutes(),:899): routes every line in id order, discarding the markup, until RouterCore's registry version stops changing ortrunk_discovery_max_passes(default 4) is reached, so bundling and crossing results do not depend on YAML order. - Pass 2b, lines in declaration order, through
LineOverlaywith the complete anchor set (static plus virtual). - Z-order pass: every cached overlay element (lines, shapes and the control
<foreignObject>s, whichMsdControlsRendererputs in the cache) is re-appended to#msd-overlay-containersorted byOverlayUtils.compareByZIndex()(z_index, else the type default fromDEFAULT_Z_BY_TYPE: control 200, line 100, shape 50; declaration order breaks ties).
(The renderer still carries an empty "pass 1" for early overlay types; no type uses it.)
DOM produced
#msd-v1-comprehensive-wrapper aspect-ratio from the view box; opacity 0 until revealed
├─ div[data-msd-background-layer] background_animation canvas (z-index -1), when configured
└─ div
└─ svg[viewBox] the base SVG (or an empty one for source: none)
├─ g#__msd-base-content base SVG children; display:none with render_visual: false
├─ g#msd-overlay-container after the z-order pass: every overlay, sorted
│ ├─ g[data-overlay-id] line / shape markup
│ └─ foreignObject#<id>[data-overlay-id][data-overlay-type="control"]
│ └─ div.msd-control-wrapper
│ └─ hui-card wraps the embedded card (visibility: support)
└─ g#msd-controls-container where controls are first inserted; emptied by the z-order passKey Classes
| Class / function | File | Role |
|---|---|---|
initMsdPipeline() | src/msd/pipeline/PipelineCore.js | Entry point: runs the stages above, defines reRender(), returns the pipeline API (createPipelineApi()) or a disabled pipeline |
processAndValidateConfig() | src/msd/pipeline/ConfigProcessor.js | A module function, not a class: view box, anchor harvesting and merging, CoreConfigManager.processConfig(), percentage resolution, anchor reference errors |
AnchorProcessor | src/msd/pipeline/AnchorProcessor.js | Static helpers: harvests SVG element anchors (through window.lcards.findSvgAnchors), resolves percentage coordinates, merges the three anchor layers |
SvgStructureAnalyzer | src/msd/pipeline/SvgStructureAnalyzer.js | Rasterizes the base SVG to a mask and derives landmark anchors (analyzeAnchors()); the MSD Studio Shield Bubble flow uses its boundary tracing (analyzeShieldBubbleRaw(), splitBoundaryIntoSections()) |
MsdCardCoordinator | src/msd/pipeline/MsdCardCoordinator.js | Per-card owner of the router and renderers; holds the single per-card HASS (ingestHass() / getHass()), applies rule base_svg filter updates (_applyBaseSvgUpdate()), tears down in destroy() |
buildCardModel() | src/msd/model/CardModel.js | Resolves base_svg source, filters and animations, the view box, anchors, and normalizes the overlay list (overlaysBase) |
ModelBuilder | src/msd/pipeline/ModelBuilder.js | Builds the resolved model on every reRender(): merges each overlay's raw config with its card-model entry, resolves theme: tokens in style |
AdvancedRenderer | src/msd/renderer/AdvancedRenderer.js | Render orchestrator: phased render, route discovery, z-order pass, attachment points; the targeted update path updateLineEntityColors() |
MsdControlsRenderer | src/msd/controls/MsdControlsRenderer.js | Control overlays: builds the embedded card (inside hui-card), positions it in a <foreignObject> in view box space, registers its attachment points, forwards HASS to the controls whose entities changed |
OverlayBase | src/msd/overlays/OverlayBase.js | Base class of the instance renderers (LineOverlay, ShapeOverlay): lifecycle (initialize, render, destroy), animation targets. Overlays have no data subscriptions: a change re-renders the card or patches the DOM (see the table under Rendering). Extends BaseRenderer. Controls do not use it |
LineOverlay | src/msd/overlays/LineOverlay.js | Per-line renderer: resolves endpoints, asks RouterCore for the route, builds the SVG path and markers, resolves the line's colour |
ShapeOverlay | src/msd/overlays/ShapeOverlay.js | shape overlays (polyline/rect/circle); a sibling of LineOverlay, not a subclass |
RouterCore | src/msd/routing/RouterCore.js | Pathfinding engine, one instance per card. See Routing Engine |
AttachmentPointManager | src/msd/renderer/AttachmentPointManager.js | Per-render store of overlay attachment points and named anchors used as line endpoints |
BaseRenderer | src/msd/renderer/BaseRenderer.js | Shared helpers for overlay renderers: theme manager lookup, defaults, style-resolution provenance, scaling context |
OverlayUtils | src/msd/renderer/OverlayUtils.js | Position resolution, 9-point bbox attachment points, z-index defaults and comparison (DEFAULT_Z_BY_TYPE, compareByZIndex()) |
RendererUtils | src/msd/renderer/RendererUtils.js | Lower-level geometry and SVG helpers used by OverlayUtils and the overlays |
BaseSvgFilters | src/msd/utils/BaseSvgFilters.js | applyBaseSvgFilters(), transitionBaseSvgFilters(), clearBaseSvgFilters() on #__msd-base-content |
Overlay Types
| Type | Rendered by | Description |
|---|---|---|
control | MsdControlsRenderer | Any Home Assistant card (including LCARdS cards) in a <foreignObject> at view box coordinates. The card config comes from the overlay's card:; LCARdS cards get the overlay id as their id and the overlay's tags |
line | LineOverlay | Routed SVG path from an anchor, overlay or [x, y] to another |
shape | ShapeOverlay | kind: polyline (a path through RouterCore forced to manual), rect/circle (native <rect>/<ellipse> with controls' position + size) |
AdvancedRenderer._getRendererForOverlay() (:963) decides: line and shape get a cached instance renderer; control (and any custom:, hui- or known Home Assistant card type) returns null, which sends the overlay to MsdControlsRenderer.
Control overlays (MsdControlsRenderer)
- Building the card.
createControlElement()(:824) wraps the card config inhui-card(createHuiCardWrapper()fromsrc/utils/ha-card-factory.js) so Home Assistant's ownvisibility:evaluation runs; Studio passeseditModeso the preview always shows. Withouthui-cardit falls back tocreateCardElement(). The config is the overlay'scard:(or its nestedconfig:), with_msdGenerated: true. - Positioning (
positionControlElement(),:1272). Resolvesposition(anchor name, another control's id withposition_side, or[x, y]) andsize, applies theattachmentoffset, and creates a<foreignObject>withid,data-msd-control-id,data-overlay-idanddata-overlay-type="control".data-overlay-idis what PipelineCore's animation lookup needs. The card getsdata-msd-design-size="W,H"soLCARdSCardsizes to the design size and scales with the SVG. - Attachment points.
_computeAttachmentPointsFromBox()registers the 9-point box (with kebab-case corner aliases) in the renderer'sAttachmentPointManager, so lines can attach to the control. - HASS forwarding (
setHass(),:266). Cards in a<foreignObject>inside the MSD's shadow root do not get HASS from Home Assistant's tree, so the renderer forwards it. It tracks each control's entities (_controlEntityMap, from the card config strings and the overlay'striggers_update) and only updates controls whose entities changed: an entity's state object differs from the last update's (Home Assistant replaces it on any change, attributes included), checked for each control's own entities only (_getAffectedControls()). Until 2026-11-17 it scanned every entity and compared onlystateandlast_changed, so attribute-only changes (a light's brightness) never reached a control's card. A control withtriggers_update: allalways updates; card-widemsd.triggers_update: allupdates every control on every tick. - Locked controls get
pointer-events: noneonly in Studio (_resolvePointerEvents()); on a dashboardlockedhas no effect.
Base SVG & Anchors
The MSD renders a base SVG (base_svg.source: a builtin: key, a /local/ path, a URL or a media-source:// item; or none for a blank canvas sized by view_box). The card wraps its children in <g id="__msd-base-content"> (_wrapSvgContentForRender(), lcards-msd.js:1971), the group filters, rule base_svg updates and base_svg.animations target.
Anchors are named points that overlays reference by name (position, anchor, attach_to, polyline points). Three layers, lowest precedence first (AnchorProcessor.processAnchors()):
| Layer | Source | Turned off by |
|---|---|---|
| Landmark anchors | SvgStructureAnalyzer.analyzeAnchors(): rasterizes the SVG (at most 960 px on the long side, cached by content hash), closes small gaps, and finds lateral_a, lateral_b, extremity_bow, extremity_stern, extremity_top, extremity_bottom, hull_center | base_svg.harvest_landmarks: false |
| SVG element anchors | findSvgAnchors() (src/utils/lcards-anchor-helpers.js:28): any <circle>, <ellipse>, <text> or <rect> with an id becomes an anchor named by that id (circles and ellipses at cx,cy, text at x,y, rects at the centre of their box, mapped through the element's transform). A <g> with an id is placed at the centre of its bounding box (getBBox(), mapped through the group's transform); where there is no layout engine, at the centre of the anchors inside it, and a group with neither is left out, so a reference to it is reported as a missing anchor. Ids starting with __ or msd-internal- are skipped | base_svg.harvest_svg_elements: false |
| Config anchors | msd.anchors: [x, y], numbers or percentages of the view box ("50%") | - |
Overlay ids are anchors too: a line can anchor/attach_to any overlay id, and a control's position can name another control. Percentages in an overlay's own position/anchor/attach_to arrays are resolved against the view box in processAndValidateConfig().
type: custom:lcards-msd-card
msd:
base_svg:
source: builtin:ncc-1701-a-blue
overlays:
- id: warp_status
type: control
position: warp_core # an anchor harvested from the SVG (e.g. <circle id="warp_core">)
size: [200, 90]
card:
type: custom:lcards-button
preset: lozengeChanging anchors at runtime: pipelineApi.setAnchor(id, [x, y]) writes the anchor into the card model and the current resolved model, invalidates every cached route and calls renderer.render() directly.
Line Routing
All pathfinding lives in RouterCore (one instance per MSD card, shared by every line and polyline shape). LineOverlay resolves a line's endpoints and asks RouterCore for the path; AdvancedRenderer runs the pre-render discovery loop described above so the router's shared trunk and crossing registries settle before the real pass consumes the cached routes.
The engine provides: A* grid routing with obstacle avoidance, cardinal anchor_side/attach_side guarantees, trunk-and-branch bundling (parallel lines share evenly spaced lanes; channels are pre-seeded trunks), crossing avoidance, and corner rounding, beveling and smoothing.
Full internals (registries, derived lane assignment, convergence discipline, caching): Routing Engine (RouterCore). User-facing configuration: Line Routing. Manual waypoints: Manual Routing.
Shape Attachment Points
shape overlays register into AttachmentPointManager the same way controls do, so a line can attach_to one. This happens inline in AdvancedRenderer's pass 2a, right after each shape renders (before any line that might target it):
rect/circle:OverlayUtils.computeAttachmentPoints()(the same box math controls use) registers the standard 9-point grid, plus kebab-case aliases for the 4 corners (top-left,top-right,bottom-left,bottom-right) alongside the camelCase keys. The alias matters:LineOverlay._resolveAttachTo()lowercasesattach_sidebefore building its virtual-anchor lookup key, and'topLeft'.toLowerCase()gives'topleft', which matches neither casing; only the kebab-case alias survives. Controls register the same aliases inMsdControlsRenderer._computeAttachmentPointsFromBox().polyline: each resolved vertex is registered on its own as<overlayId>.vertex<N>(AttachmentPointManager.setAnchor()), since the fixed 9-key box cannot represent any number of vertices.
The MSD Studio editor's Connect Mode overlay (_renderAttachmentPointsOverlay() in the Studio dialog) and its drag-snap detector (_getAttachmentTargetAt()) render and detect shape attachment points with the same convention, so clicking or snapping onto a shape in the editor produces an attach_side that resolves at runtime.
Shape design notes
- Sibling, not subclass. A line's
anchor/attach_to/attach_sideresolution and fallback rendering would be wrong for a shape, soShapeOverlayextendsOverlayBasedirectly. Its_resolveShapeStyles()is adapted from the functional subset ofLineOverlay._resolveLineStyles(): a deliberate, scoped duplication, kept until a second consumer needs exactly the same logic (see the file header). - Polyline corners for free. Because
polylinegoes throughRouterCore.buildRouteRequest()/computePath()inmanualmode,corner_style,corner_radius,corner_angle,smoothing_modeandsmoothing_iterationswork as they do on lines.RouterCore._cacheKey()foldsreq.waypointsinto the key, so moving an interior point with unchanged endpoints never hits a stale path;ShapeOverlay's ownrouterCore.invalidate(overlay.id)before eachcomputePath()is belt and braces, not load-bearing. rect/circlegeometry. Acirclerenders as<ellipse>withrx = size[0] / 2,ry = size[1] / 2(a strict superset of<circle>). There is noattachmentoffset map:positionis always the top-left corner.corner_radiusmaps torx/ryonrectand does nothing oncircle.- Fill is first-class. On lines fill only matters for self-intersecting paths; on shapes
style.filltakes the same state-color object asstyle.color, resolved against the shape's ownentity/state_attribute/ranges_attribute. Both live paths,AdvancedRenderer.updateLineEntityColors()and the card's rule DOM patch, refreshfillalongside the stroke. A third live-refreshed property must be added to both: fill once shipped refreshing on only one of them, and silently never updated live. - Why
lockedis not on lines. Line and polyline hit-testing uses the real rendered path, not a bounding box, so a line never blocks the overlays under it the way a large, mostly empty control or shape box does. A locked overlay's Studio hit box getspointer-events: noneso clicks fall through; it stays editable from its list-panel lock icon and property form.
Delta Updates
reRender() rebuilds every overlay: the overlay group is emptied, controls are recreated, every line is routed again and on_load animations run again. To avoid that, most live changes take a targeted path instead:
| Change | Path | What it touches |
|---|---|---|
| HASS update (every tick) | MsdCardCoordinator.ingestHass() -> _propagateHassToSystems() | MsdControlsRenderer.setHass() (controls whose entities changed), then AdvancedRenderer.updateLineEntityColors(hass): lines and shapes with an entity or a template colour get their stroke, fill and match_line markers re-resolved and patched in place |
| Alert mode change | LCARdSMSDCard._onAlertModeChanged() | updateLineEntityColors(hass, { all: true }) (every line and shape, since plain colours were resolved to concrete values at paint time) and the background animation colours |
| Template colour inputs change | _handleHassUpdate() -> _processCustomTemplates() | Re-evaluates the templates, then coordinator.ingestHass(), which reaches updateLineEntityColors(); deliberately no reRender() |
| Style-only rule patch | _applyRulePatches() -> _onRulePatchesChanged() -> _applyStylePatchesToDOM() | Writes stroke, fill, opacity and similar attributes on the line, shape or control element; no re-render. _onMsdRendered() re-applies them after any later full render |
Rule apply.base_svg | _applyRuleResults() -> coordinator._applyBaseSvgUpdate() | Transitions the filters on #__msd-base-content (transition ms, default 1000); restores the configured filters when no rule matches |
| Rule patch with non-style keys | _onRulePatchesChanged() | Writes patched overlays into coordinator.mergedConfig.overlays and cardModel.overlaysBase, then a full reRender() |
Live view_box change | _reconcileViewBoxIfChanged() | cardModel.viewBox, router.setViewBox(), then a full reRender() |
Embedded cards update themselves: an LCARdS card inside a control registers with the rules engine under its overlay id (the MSD skips registering LCARdS controls itself) and receives HASS from MsdControlsRenderer.
Rules Integration
The MSD uses the core rules engine like other cards (see Rules Engine), with one difference: patches are keyed per overlay.
_registerOverlaysWithRulesEngine()(lcards-msd.js:547) registers the card itself with_registerOverlayForRules(this._cardGuid, 'msd-card'), then every overlay that is not an LCARdS control directly withsystemsManager.registerOverlay(id, { id, type, tags: ['msd-overlay', type, ...tags], sourceCardId }), sotag:andtype:selectors reach lines, shapes and non-LCARdS controls. It clearsthis.hassduring registration so evaluation runs once at the end, marks every rule dirty, and runs the card's rules callback when HASS is present._applyRulePatches(overlayPatches)(:653) merges the patches into{ overlayId: patch }(mergeOverlayPatches(): highest priority wins per key) and skips unchanged maps.- Do not call
_getMergedStyleWithRules()in MSD overlay renderers: rule patches reach overlays through the paths in the table above.
Lifecycle and Teardown
- First mount:
_onFirstUpdated()->_loadAndInitializeMsd(). - Reconnect (edit mode toggle, view change):
disconnectedCallback()called_cleanupMsdPipeline(), so_onConnected()sees_initialized && !_msdInitializedand runs_loadAndInitializeMsd()again. The loaded SVG text (_svgContent) and the instance GUID are kept across reconnects. - Moved during initialisation (#409):
_cleanupMsdPipeline()bumps_msdGeneration. A load started under an older generation is stale: it stops at its next await (a pipeline it already built is destroyed) and never touches the card's flags._loadAndInitializeMsd()reuses an in-flight load only of the current generation; otherwise it waits for the stale one to finish, then loads again. Before this, the reconnect awaited the stale load, which could never reveal the card, so it stayed on "Initializing MSD..." (tests/browser/msd-reconnect.spec.js). - Teardown (
_cleanupMsdPipeline(),lcards-msd.js:1338):_destroyMsdAnimationScopes()first, while the overlay elements are still in the card: it destroys__msd_base_svg:<guid>,__msd_animations:<guid>and every overlay-id scope whose element is in this card's render root (another MSD may use the same overlay id), so a removed card leaves no detached SVG,TriggerManagersubscriptions or running loops in the sharedAnimationManager(lcards-msd.js:1377;tests/browser/msd-animation.spec.js). Thencoordinator.destroy(), then clears_msdPipeline,_msdInitialized,_msdRevealedand destroys the background renderer. MsdCardCoordinator.destroy()(MsdCardCoordinator.js:237) never destroys theDataSourceManager(it is the shared core singleton), runs the controls renderer'scleanup()(removes the controlforeignObjects and the controls container, clears its entity maps and HASS), destroys the renderer's cached overlay instances, clears timers and drops the per-card references (renderer,controlsRenderer,router). The shared singletons (themeManager,dataSourceManager,animationManager,stylePresetManager) are left alone.
Pipeline API
initMsdPipeline() returns this object (createPipelineApi(), PipelineCore.js:696), stored on the card as _msdPipeline:
| Member | Description |
|---|---|
enabled | true (false on a disabled pipeline) |
version | mergedConfig.version or 1 |
config | The full card config passed in (deep clone, with __provenance) |
msdConfig | The processed, flat msd config (mergedConfig, with __issues) |
coordinator | The MsdCardCoordinator |
router, renderer | coordinator.router (RouterCore), coordinator.renderer (AdvancedRenderer) |
dataSourceManager, validationService | The shared core services as the coordinator holds them. Rules: window.lcards.core.rulesManager |
reRender() | Full re-render (serialized, see above); returns the renderer result or { success: false, ... } |
getResolvedModel() | The last resolved model (ModelBuilder.getResolvedModel()) |
setAnchor(id, [x, y]) | Sets an anchor, invalidates routes, renders; returns false for bad input |
getAnchors() | Copy of the card model's anchors |
routingInspect(id), routingInspectAll() | Read-only RouterCore.inspect() / inspectAll() of the route cache; never routes |
ingestHass(hass) | Forwards to coordinator.ingestHass() |
getDataSourceManager() | Same as dataSourceManager |
setCardInstance(card) | Stores the card on coordinator.cardInstance (actions, state colours, _onMsdRendered()) |
updateEntities(), getActiveProfiles() | Leftovers: updateEntities() only logs, getActiveProfiles() returns [] |
A disabled pipeline (enabled: false) carries issues ({ errors, warnings }, what the card's error panel shows), the same lists as errors / warnings, html (an error panel), config, msdConfig and no-op versions of the getters. Each issue's text is in message (msdIssueText() in lcards-msd.js also reads the older msg and plain strings).
For console debugging use window.lcards.debug.msd.* (src/api/MsdDebugAPI.js; pipeline.getInstance(), pipeline.rerun(), overlays.tree(), routing.inspect(), routing.trunks()): see Debug API.
Animations
All three overlay types and base_svg.animations register through the shared AnimationManager (see Animation Manager); preset parameters live in src/cards/schemas/animation-preset-params-schemas.js and map_range in src/core/animation/resolveAnimParams.js. User docs: MSD Animations.
- Finding the element. After rendering,
PipelineCorelooks each animated overlay up as[data-overlay-id="<id>"]. Lines and shapes carry it on their<g>;MsdControlsRenderersets it on each control's<foreignObject>for exactly this lookup. - Target scope. An overlay's animation
targetselector runs inside that overlay's own rendered subtree (overlayElement.querySelectorAll(selector)).base_svg.animationsrun in the synthetic__msd_base_svgscope over#__msd-base-content, which is also the editor target picker'ssearchRootSelector. - Rule-only targets.
PipelineCorecallsonOverlayRendered()only for overlays with registered animations. So that a rule'sapply.animationscan still play on an overlay with none of its own,AnimationManager.initialize()registers an empty entry for every overlay a rule targets directly withoverlay:. Rules that select bytag:,type:orpattern:get no such entry, because the overlay list passed toinitialize()does not carry tags or types; against an overlay without its own animations they find no scope. - Moving along a line. The
motionpathpreset'sparams.shapedraws its own tracer and moves it along the path, which suits "energy flowing along a line". Targeting an existing control or base SVG element is only for moving something that already exists for another reason.
MSD Studio
The visual editor is src/editor/dialogs/lcards-msd-studio-dialog.js (helpers in src/editor/dialogs/msd-studio/).
- Shared chrome.
studio-dialog-styles.jsstyles the main frame of every Studio dialog (Chart, Layout, Data Grid, MSD);studio-subform-dialog-styles.jsstyles nested subforms (line and control forms, the embedded card editor). The subform classes are.subform-*so they never collide with the main dialog's canvas lookups (.preview-panel,.config-panel). - Live preview.
lcards-msd-live-preview.jsrecreates the preview<lcards-msd-card>on every config change (debounced 300 ms; a HASS tick only setscard.hass), so any element reference goes stale. Consumers re-fetch it with_getLivePreviewCardElement(). - Self-healing retry. Two mechanisms keep a consumer such as the animation editor's target picker current. A "Refresh Element List" button dispatches
refresh-targets, which the parent handles withthis.requestUpdate(), re-fetching the card. Because users rarely know when to press it, the component whose scoped query comes back empty (<lcards-animation-editor>'s_getTargetOptions()with itssearchRootSelector) dispatchesrefresh-targetsitself and also calls its ownrequestUpdate(). The second call matters: when the parent's re-fetch returns the same object (the preview was not swapped, just not rendered yet), Lit's!==property check would not re-render the child. The retry (_requestTargetRediscovery()) is bounded at 10 attempts, 250 ms apart, reset on the next successful lookup, so a selector that can never match stops. A fixed-delaysetTimeoutwas tried first and proved unreliable: neither the preview debounce nor the pipeline's render time is fixed. - Editing in place. The array index of the overlay being edited comes from the id captured when the form opened (
_editingControlId,_editingLineId), not the editable id field, so renaming while editing updates in place instead of adding a duplicate. - Saving. A save spreads the existing overlay before the form's fields (
{ ...existingOverlay, ...explicitFields }), so keys the form does not manage survive. Controls, lines and shapes each have an Animations subtab (_renderControlFormAnimation(),_renderLineFormAnimation(),_renderShapeFormAnimation()) whose animations are saved explicitly rather than relying on the spread. - Debug canvas overlays (grid, bounding boxes, channels, routing grid, discovered trunks and so on) share one pattern: an
overlayTogglesentry{ key, prop, icon, tooltip }, a_<prop>reactive property defaulting tofalse, a_render<X>Overlay()method using_getPreviewSvgAndViewBox()'s coordinate transform, and a call in the overlay render list. The Routing Grid (amber,router.resolvedGridResolution()) and Discovered Trunks (cyan,router.trunks()rows withorigin: 'discovered'; authored channels are left to the channels overlay) reach the live router throughpreview.msdCard._msdPipeline?.coordinator?.router. - No config-driven debug. These overlays are editor-only HTML driven by the dialog's reactive properties (
_showBoundingBoxesand so on). The old card-levelmsd.debugoption and the renderer that read it (MsdDebugRenderer) are gone; nothing in the saved card config turns debug drawing on.
Removed line and shape style keys
style.glow, glow_color, glow_size, pulse_speed, flow_speed, a style-level smoothing enum, segment_colors and status_indicator were parsed but never rendered, so they were removed from the schema. The glow, pulse and march animation presets cover the same effects.
See Also
- MSD Card: User Guide
- Control Overlay
- Line Overlay
- Shape Overlay
- Manual Routing
- Routing Engine (RouterCore)
- Card Foundation
- Core services the pipeline uses: Config Manager, Asset Manager, Theme System, Data Source System, Animation Manager, Rules Engine, Systems Manager
- Background Animation System (the
background_animationlayer)