Systems Manager
window.lcards.core.systemsManager— Centralised entity state subscriptions and push notifications.
Overview
CoreSystemsManager is the shared entity state cache for all LCARdS cards. Instead of every card individually subscribing to HASS state updates, cards register with the Systems Manager and receive targeted callbacks only when entities they care about actually change.
File
src/core/systems-manager/index.js
Responsibilities
- Maintain a
Map<entityId, stateObject>cache updated on every HASS push - Allow cards to subscribe per entity ID with a callback
- Deduplicate subscriptions — N cards watching the same entity = one internal subscription
- Provide overlay registry used by the
RulesEnginefor cross-card targeting - Batch rapid state changes using a microtask queue
Overlay Registry
Cards register their overlays here so the Rules Engine can target them by ID, tag, or type:
javascript
const sm = window.lcards.core.systemsManager;
sm.registerOverlay({
id: `button-${this._cardGuid}`,
tags: ['temp', 'status'],
type: 'button',
element: this
});
// On disconnect:
sm.unregisterOverlay(`button-${this._cardGuid}`);Entity Subscription API
javascript
const sm = window.lcards.core.systemsManager;
// Subscribe — returns unsubscribe function
const unsub = sm.subscribeToEntity('sensor.temperature', (state) => {
this._temp = state;
this.requestUpdate();
});
// Get cached state (synchronous, no subscription)
const state = sm.getEntityState('sensor.temperature');
// In disconnectedCallback:
unsub();HASS Update Flow
card.set hass(newHass)
→ LCARdSNativeCard.ingestHass(newHass)
→ CoreSystemsManager.updateHass(newHass)
→ diff entity states
→ notify subscribers for changed entities only