ESPCDFAutomation
ESPCDFAutomation represents a rule that runs actions when node, weather, or daylight conditions match. Use it to enable, edit, or delete automations after they are created via ESPCDFGroup.createAutomation.
Automations live in AutomationStore. The synchronizer listens on operationsEvents (not events) — the only entity that uses this bus name.
Do not construct automations in UI code; adaptors return them from group operations.
Properties
| Property | Type | Description |
|---|---|---|
id / name | string | Identity |
enabled | boolean | Active flag (updated by synchronizer) |
eventType | typed | node, weather, or daylight |
events / actions | arrays | Trigger and action definitions |
location | optional | Geo for weather/daylight automations |
operationsEvents | ESPCDFOperationEventEmitter | Subscribe here for operation events |
operations | ESPCDFAutomationOperation | SDK delegates |
_raw | any | Original SDK automation |
Common Workflows
Get an automation from the store
import { initCDF } from "@espressif/rainmaker-base-cdf";
const espCDF = await initCDF({ sdkAdaptorRegistry });
const automation = espCDF.automationStore.getAutomationById("auto-id");
Enable or disable
await automation!.enable(true);
await automation!.enable(false);
// Or read local flag
const on = automation!.isEnabled();
Update definition
await automation!.update({
name: "Night mode",
enabled: true,
events: [...],
actions: [...],
});
Delete
await automation!.delete();
// AutomationStoreSynchronizer removes it from the store
Subscribe to operation events
const unsubscribe = automation!.subscribe((entity, op, success, data, err) => {
if (!success) console.error(op, err);
});
// Clean up on unmount
unsubscribe();
Error Handling
try {
await automation!.update({ enabled: false });
} catch (e) {
showErrorBanner("Could not update automation");
}
Failures re-throw and emit on operationsEvents so synchronizers can log without partial store patches.
Event types
eventType | Typical use |
|---|---|
node | Trigger on device param thresholds |
weather | Trigger on weather conditions (needs location) |
daylight | Sunrise/sunset style triggers |
Filter automationStore.automationsList by eventType in UI when you need separate lists — the store exposes one combined list.
Related Resource
- Automation store
- ESPCDFGroup — create and fetch automations
- ESPCDFAutomation source
- API Reference: