跳到主要内容

ESPCDFService

ESPCDFService is an optional service slice on a node (for example schedules, scenes, or system services) with its own param list. Use it when the node tree exposes capabilities outside standard ESPCDFDevice entries.

Services appear on ESPCDFNode.services when the adaptor maps them. Param updates go through ESPCDFServiceParam.


Properties​

PropertyTypeDescription
namestringService name
typestringService type id
paramsESPCDFServiceParam[]Service parameters
operationsESPCDFServiceOperationSDK delegates
_rawanyOriginal SDK service
eventsESPCDFOperationEventEmitterOperation bus

Common Workflows​

List services on a node​

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

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

for (const service of node?.services ?? []) {
console.log(service.name, service.type);
}

Refresh service params​

const service = node!.services!.find((s) => s.name === "Schedule")!;
const params = await service.getParams();

Set a service param​

const param = service.params.find((p) => p.name === "enabled");
await param?.setValue(true);

Error Handling​

try {
await service.getParams();
} catch (e) {
showErrorBanner("Failed to load service params");
}


On this page