Skip to main content

ESPCDFNode

ESPCDFNode represents one RainMaker backend node — devices, services, connectivity, transports, and OTA. Use it when you control params, check online status, or run firmware updates for a single device endpoint.

Nodes live in NodeStore after user.getNodeDetails, group.getNodes, or provisioning flows. Read them with nodeStore.getNodeById or nodeStore.nodesList.

Operation methods use runAndEmit. Property-change events (onPropertyChange) are separate from operation events and keep _raw aligned after push updates or store patches.


Properties

PropertyTypeDescription
identifierstringAdaptor id
idstringNode id
connectivityStatusoptionalCloud/local reachability
nodeConfigESPCDFNodeConfig | undefinedConfig snapshot
devices / servicesarrays | undefinedDevice and service entities
availableTransportsoptionalLocal transport configs
operationsESPCDFNodeOperationSDK operations
_rawanyOriginal SDK node
eventsESPCDFOperationEventEmitterOperation event bus

Common Workflows

Get a node from the store

import { initCDF } from "@espressif/rainmaker-base-cdf";

const espCDF = await initCDF({ sdkAdaptorRegistry });
const node = espCDF.nodeStore.getNodeById("node-id");

Set device parameters

const node = espCDF.nodeStore.getNodeById("node-id")!;

await node.setMultipleParams({
Light: { Power: true, Brightness: 80 },
Fan: { Speed: 3 },
});

Change one param

const powerParam = node.devices?.[0]?.params?.find((p) => p.name === "Power");
await powerParam?.setValue(true);

Check connectivity

Connectivity updates arrive via the subscription path and are reflected on the observable field:

const online = node.connectivityStatus?.connected ?? false;

Update metadata and timezone

await node.updateMetadata({ location: "Kitchen" });
await node.setTimeZone("Asia/Kolkata");

OTA firmware

const { data: otaInfo } = (await node.checkOTAUpdate?.()) ?? {};
if (otaInfo?.available) {
await node.pushOTAUpdate?.({ firmwareImageId: otaInfo.imageId } as any);
}
const status = await node.getOTAUpdateStatus(otaJobId);

Remove a node

await node.delete();
// NodeStoreSynchronizer removes it from the store

Error Handling

try {
await node.setMultipleParams({ Light: { Power: true } });
} catch (e) {
showErrorBanner("Failed to update device");
}

Optional OTA methods (checkOTAUpdate, pushOTAUpdate) exist only when the adaptor wires them — call with optional chaining or guard before use.


Property-change sync with _raw

Register in the node transformer so observable updates mirror back to the SDK object:

node.onPropertyChange((event) => {
// Adaptor patches sdkNode — see Synchronizers
});

Stores and nodeEventHandlers may call emitPropertyChange after push updates:

node.emitPropertyChange({
type: "connectivityStatusChanged",
connectivityStatus: status,
entity: node,
});

On this page