feat: Add event-based automation triggers (#2537)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent b701366762
commit a31816c168
109 changed files with 4607 additions and 1623 deletions
+18 -3
View File
@@ -122,7 +122,7 @@ export class CardController
private _expandManager = new ExpandManager(this);
private _foldersManager = new FoldersManager(this);
private _fullscreenManager = new FullscreenManager(this);
private _hassManager = new HASSManager(this);
private _hassManager: HASSManager;
private _initializationManager = new InitializationManager(this);
private _interactionManager = new InteractionManager(this);
private _keyboardStateManager = new KeyboardStateManager(this);
@@ -133,7 +133,7 @@ export class CardController
private _microphoneManager = new MicrophoneManager(this);
private _notificationManager = new NotificationManager(this);
private _pipManager = new PIPManager(this);
private _issueManager = createIssueManager(this);
private _issueManager: IssueManager;
private _queryStringManager = new QueryStringManager(this);
private _statusBarItemManager = new StatusBarItemManager(this);
private _styleManager = new StyleManager(this);
@@ -145,8 +145,13 @@ export class CardController
host: CardHTMLElement,
scrollCallback: ScrollCallback,
menuToggleCallback: MenuToggleCallback,
hassManager?: HASSManager,
) {
host.addController(this);
this._hassManager = hassManager ?? new HASSManager(this);
this._issueManager = createIssueManager(
this,
this._hassManager.getEventWatcher().getHealth(),
);
this._cardElementManager = new CardElementManager(
this,
@@ -154,6 +159,16 @@ export class CardController
scrollCallback,
menuToggleCallback,
);
// ConditionStateManager MUST be wired first so its `hass` is current before
// any later listener fires. Otherwise StateWatcher could fire a
// camera-trigger handler that writes back to ConditionStateManager, fanning
// out to automations that still read a stale `hass`.
this._hassManager.addListener((hass) =>
this._conditionStateManager.setState({ hass }),
);
host.addController(this);
}
// *************************************************************************