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

Implementation Guidelines:

  • channelId should be unique and descriptive (e.g., "notification", "matter", "mqtt")
  • 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,
        nodeId?: string,
    ): Promise<void>;
    supportsNode(node: ESPRMNode): boolean;
    unsubscribe(nodeId?: string): Promise<void>;
}

Implemented by

Properties

channelId: string

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

Methods

  • Cleanup and dispose of resources. Called when channel is unregistered or app is closing.

    This should:

    • Close connections
    • Clear callbacks
    • Release resources
    • Perform any channel-specific cleanup (e.g., delete notification endpoint)

    Returns Promise<void>

    Promise that resolves when disposal is complete

  • 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 or all nodes.

    Parameters

    • callback: (update: ESPNodeUpdateData) => void

      Function to call when updates are received

    • OptionalnodeId: string

      Optional node ID. If provided, only updates for this node trigger the callback

    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:

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

    Parameters

    • node: ESPRMNode

      The node to check support for

    Returns boolean

    true if this channel can provide updates for the node

  • Unsubscribe from updates for a specific node or all nodes.

    Parameters

    • OptionalnodeId: string

      Optional node ID. If not provided, unsubscribes from all nodes

    Returns Promise<void>

    Promise that resolves when unsubscription is complete