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
| Property | Type | Description |
|---|---|---|
identifier | string | Adaptor id |
id | string | Node id |
connectivityStatus | optional | Cloud/local reachability |
nodeConfig | ESPCDFNodeConfig | undefined | Config snapshot |
devices / services | arrays | undefined | Device and service entities |
availableTransports | optional | Local transport configs |
operations | ESPCDFNodeOperation | SDK operations |
_raw | any | Original SDK node |
events | ESPCDFOperationEventEmitter | Operation 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,
});
Related Resource
- Node store
- Subscription store — push updates into node observables
- ESPCDFNode source
- API Reference: