feat: Add event-based automation triggers (#2537)
This commit is contained in:
committed by
dermotduffy
parent
b701366762
commit
a31816c168
@@ -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;
|
||||
Reference in New Issue
Block a user