Skip to article frontmatterSkip to article content

Endpoint Management in Bridges

Overview

Each bridge exposes child endpoints representing Home Assistant entities. These endpoints are managed and updated to reflect the current state of Home Assistant.

BridgeEndpointManager

const manager = new BridgeEndpointManager(client, registry);
manager.startObserving();

HomeAssistantRegistry.enableAutoRefresh

enableAutoRefresh = initBridges
  .then(() => Promise.all([registry$, bridgeService$]))
  .then(([r, b]) => r.enableAutoRefresh(() => b.refreshAll()));

Endpoint Update Flow

  1. Home Assistant entity state changes.

  2. Registry triggers auto-refresh callback.

  3. BridgeService refreshes all bridges.

  4. BridgeEndpointManager updates endpoints/devices.

State Update Flow

  1. BridgeEndpointManager asks BridgeRegistry for included entities.

  2. BridgeEndpointManager subscribes to all state changes of the observed entity ids.

  3. Whenever a state is changed, it notifies all endpoints about the changes.