ESPCDFScene
ESPCDFScene is a named preset that applies device params across one or more nodes in a single call. Use it when you implement scene feature.
Scenes are created with group.createScene and stored in SceneStore. Read them with sceneStore.getScene or sceneStore.sceneList.
Constructor requires id and name. Mutations use runAndEmit; SceneStoreSynchronizer keeps the store in sync.
Properties
| Property | Type | Description |
|---|---|---|
id / name | string | Required identity |
nodes | string[] | Participating node IDs |
actions | nested map | Per-node device actions |
devicesCount | number | UI helper count |
adaptorIdentifier | optional | Source adaptor |
operations | ESPCDFSceneOperation | SDK delegates |
_raw | any | Original SDK scene |
events | ESPCDFOperationEventEmitter | Operation bus |
Common Workflows
Get a scene from the store
import { initCDF } from "@espressif/rainmaker-base-cdf";
const espCDF = await initCDF({ sdkAdaptorRegistry });
const scene = espCDF.sceneStore.getScene("scene-id");
Activate a scene
Applies all actions on member nodes:
await scene!.activate();
You can also activate via the store:
await espCDF.sceneStore.activateScene("scene-id");
Rename a scene
await scene!.edit({ name: "Chill Night" });
Delete a scene
await scene!.remove();
Create via group (typical path)
const group = espCDF.groupStore.getGroupById("group-id")!;
const capable = await group.getSceneCapableDevices();
const newScene = await group.createScene({
id: "scene-evening",
name: "Evening",
nodes: ["node-1"],
actions: { "node-1": { Light: { Power: true, Brightness: 50 } } },
});
Error Handling
try {
await scene!.activate();
} catch (e) {
showErrorBanner("Scene activation failed");
}
Actions shape
actions is a nested map: node id → device name → param payload:
actions: {
"node-1": { Light: { Power: true, Brightness: 80 } },
"node-2": { Fan: { Speed: 2 } },
}
Related Resource
- Scene store
- ESPCDFGroup
- ESPCDFScene source
- API Reference: