Interface for subscription channels that provide device parameter updates. Each channel represents a different communication method (MQTT, Matter, BLE, etc.)

Implementation Guidelines:

  • channelId should be unique and descriptive (e.g., "mqtt", "matter", "ble")
  • supportsNode() should check if the node has the required capabilities/configuration
  • subscribe() should set up the subscription and call the callback when updates arrive
  • All updates must be transformed into ESPNodeUpdateData format
interface ESPSubscriptionChannelInterface {
    channelId: string;
    dispose(): Promise<void>;
    initialize(): Promise<void>;
    subscribe(
        callback: (update: ESPNodeUpdateData) => void,
        node: NodeLike,
    ): Promise<void>;
    supportsNode(node: NodeLike): boolean;
    unsubscribe(
        nodeId?: string,
        callback?: (update: ESPNodeUpdateData) => void,
    ): Promise<void>;
}

Implemented by

Properties

channelId: string

Unique identifier for this channel (e.g., "mqtt", "matter", "ble")

Methods

  • Cleanup and dispose of all channel resources (connections, callbacks, etc.). Called when the channel is unregistered or the app is closing.

    Returns Promise<void>

  • Initialize the channel (setup connections, adapters, etc.) Called once when channel is registered with the subscription manager

    Returns Promise<void>

    Error if initialization fails

  • Subscribe to parameter updates for a specific node.

    Parameters

    • callback: (update: ESPNodeUpdateData) => void

      Function to call when updates are received

    • node: NodeLike

      The node to subscribe to. Must carry the identifier and any routing context the channel needs (e.g. groupId, subgroupIds for MQTT shadow topic construction). Passing the full node — not just an id — lets channels operate without reverse-looking up group membership from persistent state.

    Returns Promise<void>

    Promise that resolves when subscription is active

    Error if subscription fails (e.g., adapter not configured, connection failed)

  • Check if this channel supports a specific node. This method determines whether the channel can provide updates for the given node.

    Examples:

    • MQTT channel: returns true for all nodes (generic)
    • Matter channel: returns true only if node has Matter capability in its config
    • BLE channel: returns true only if node has BLE support in metadata

    Parameters

    • node: NodeLike

      The node to check support for

    Returns boolean

    true if this channel can provide updates for the node

  • Unsubscribe from updates.

    Parameters

    • OptionalnodeId: string

      Optional node ID. If omitted, unsubscribes every node.

    • Optionalcallback: (update: ESPNodeUpdateData) => void

      Optional specific subscriber to remove. When provided, only that callback is detached; the channel keeps delivering to the node's other subscribers and fully detaches the node only once none remain. When omitted, all subscribers for the node are removed.

    Returns Promise<void>

    Promise that resolves when unsubscription is complete