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
+14
View File
@@ -0,0 +1,14 @@
import { STATE_RUNNING } from 'home-assistant-js-websocket';
import { HomeAssistant } from './types';
// HA is "ready" when the WebSocket is connected AND integrations have finished
// loading (`config.state === STATE_RUNNING`). HA exposes the WebSocket before
// integrations load, so `connected` alone is insufficient for
// integration-specific calls (e.g. Frigate WS subscriptions, which fail with
// "Unknown command" against a half-loaded HA).
//
// Typed as a predicate so callers can use the readiness check to narrow a
// nullable `hass?` reference to a non-null `HomeAssistant` for follow-up
// `hass.connection`-style access.
export const isHassReady = (hass?: HomeAssistant | null): hass is HomeAssistant =>
!!hass?.connected && hass.config?.state === STATE_RUNNING;