Represents a user node in the system, managing its configuration and connectivity status. Implements the ESPRMNodeInterface.

Implements

Constructors

Properties

availableTransports: Record<string, ESPTransportConfig> = {}

Available Transports with the node.

connectivityStatus?: ESPRMConnectivityStatus

The connectivity status of the node.

customTransportManagers?: Record<string, ESPTransportInterface>

Custom transport managers associated with the node.

Custom transport managers allow you to implement your own communication protocols (e.g., Bluetooth, WebSocket, custom protocols) alongside the built-in local and cloud transports. Each custom transport must implement the ESPTransportInterface and receives a reference to the node instance, providing full flexibility to access node metadata, configuration, devices, and connectivity status.

The SDK uses transports in the priority order specified in transportOrder:

  1. If a transport mode exists in customTransportManagers, it uses the custom transport
  2. If not, it falls back to the built-in transport (local/cloud)
  3. If the transport fails, it moves to the next transport in the order
  4. If all transports fail, an error is thrown
const myCustomTransport = new MyCustomTransport();
const node = new ESPRMNode({
id: "my-node-id",
transportOrder: ["bluetooth", "local", "cloud"],
availableTransports: {
bluetooth: { type: "bluetooth", metadata: {} },
local: { type: "local", metadata: { baseUrl: "http://192.168.1.100" } },
cloud: { type: "cloud", metadata: {} }
},
customTransportManagers: {
bluetooth: myCustomTransport
}
});

Common use cases include:

  • Bluetooth Transport: Direct device communication via Bluetooth
  • WebSocket Transport: Real-time bidirectional communication
  • Custom Protocol: Implement proprietary protocols
id: string

The unique identifier of the node.

isPrimaryUser?: boolean

Indicates if the node is associated with a primary user.

metadata?: Record<string, any>

Metadata associated with the node.

nodeConfig?: ESPRMNodeConfig

The configuration settings for the node.

role?: string

Role of user associated with the node.

subscriptionConfig?: ESPNodeSubscriptionConfig

Subscription configuration for this node. Allows customization of subscription channel priority order.

If not set, the node will use the global channel order from ESPSubscriptionManager. Setting this allows per-node optimization of subscription channels.

// Set custom channel order for this node
node.subscriptionConfig = {
channelOrder: ["notification"]
};
tags?: string[]

Tags associated with the node.

transportOrder: string[] = []

Transport order associated with the node.

type?: string

The type of the node.

Methods

  • Clear the node-specific subscription channel order. After calling this, the node will use the global channel order.

    Returns void

    node.clearSubscriptionChannelOrder();
    
  • Checks the status of a previously initiated Over-The-Air (OTA) update for the node.

    Parameters

    • otaJobId: string

      The ID of the OTA job for which the status is being checked.

    Returns Promise<ESPOTAUpdateStatusResponse>

    A promise that resolves to an ESPOTAUpdateStatusResponse object containing details about the OTA update status.

    If the OTA job ID is missing or invalid.

  • Get the effective subscription channel order for this node. Returns the node-specific order if set, otherwise returns the global order.

    Returns string[]

    Array of channel IDs in priority order

    const order = node.getSubscriptionChannelOrder();
    console.log(`Channel order: ${order.join(", ")}`);
  • Initiates an Over-The-Air (OTA) update for the node using a specified OTA job ID.

    Parameters

    • otaJobId: string

      The ID of the OTA job to be used for the update.

    Returns Promise<ESPAPIResponse>

    A promise that resolves to an ESPAPIResponse object confirming the successful initiation of the OTA update.

    If the OTA job ID is missing or invalid.

  • Remove sharing of the current node for a specified user.

    Parameters

    • username: string

      The username of the user for whom the sharing is to be removed.

    Returns Promise<ESPAPIResponse>

    A promise that resolves to a success response upon successful removal.

  • Set the subscription channel order for this node. This overrides the global channel order from ESPSubscriptionManager.

    Channels are tried in the order specified until one succeeds. Only channels that support the node (via supportsNode()) will be used.

    Parameters

    • channelIds: string[]

      Array of channel IDs in priority order

    Returns void

    // Prioritize Matter for this node
    node.setSubscriptionChannelOrder(["matter", "notification", "mqtt"]);
  • Create Transfer request of the current node to a specified user.

    Parameters

    • transferNodeRequestParams: TransferNodeRequest

      Parameters specifying the user and transfer options.

    Returns Promise<string>

    A promise that resolves to a requestId upon successful transfer request creation.