ESPCDFSchedule
ESPCDFSchedule runs device actions on a time-based trigger. Use it for recurring routines such as morning lights or weekday shutdowns.
Schedules are created with group.createSchedule and stored in ScheduleStore. Access via scheduleStore.getScheduleById or scheduleStore.schedulesList.
The constructor requires id, name, at least one trigger, and a non-empty action map.
Properties
| Property | Type | Description |
|---|---|---|
id / name | string | Required identity |
triggers | ESPCDFScheduleTrigger[] | When the schedule runs |
action | ESPCDFScheduleAction | Per-node device payloads |
enabled | optional | Active flag |
outOfSyncMeta | optional | Client sync hints per node |
operations | ESPCDFScheduleOperation | SDK delegates |
_raw | any | Original SDK schedule |
events | ESPCDFOperationEventEmitter | Operation bus |
Common Workflows
Get a schedule from the store
import { initCDF } from "@espressif/rainmaker-base-cdf";
const espCDF = await initCDF({ sdkAdaptorRegistry });
const schedule = espCDF.scheduleStore.getScheduleById("schedule-id");
Enable and disable
await schedule!.enable();
await schedule!.disable();
const active = schedule!.isEnabled();
Edit a schedule
await schedule!.edit({
name: "Updated routine",
triggers: [{ m: 480, d: 127 }], // 08:00 daily
action: { "node-1": { Light: { Power: true, Brightness: 70 } } },
});
Delete a schedule
await schedule!.remove();
Create via group
const group = espCDF.groupStore.getGroupById("group-id")!;
await group.getScheduleCapableDevices();
const schedule = await group.createSchedule({
id: "sch-morning",
name: "Morning",
nodes: ["node-1"],
triggers: [{ m: 420, d: 127 }], // 07:00 every day
action: { "node-1": { Light: { Power: true } } },
enabled: true,
});
Error Handling
try {
await schedule!.edit({ name: "Weekend only", triggers: [{ m: 600, d: 65 }] });
} catch (e) {
showErrorBanner("Schedule update failed");
}
Related Resource
- Schedule store
- ESPCDFGroup
- ESPCDFSchedule source
- API Reference: