Skip to main content

Automation Rules

The rule engine lets NeoMind respond automatically without human intervention: device data crosses a threshold β†’ auto-notify, send commands, trigger an AI Agent. Rules are defined in JSON and created via Web UI, CLI, REST API, or AI Chat.

The Automation page has two tabs: Rules and Transforms. This doc covers Rules; for data transforms see Data Transforms.

Prerequisites​

  • At least one device onboarded (rules reference device metrics as data sources)
  • Notification channels configured (if using notify actions)

Interface Overview​

Click Automation (branch icon) in the left nav to open the automation page. The default tab is Rules:

Automation rules page β€” rule list, enabled status, Import/Export

The page displays all rules in a table, each row containing:

ColumnDescription
Rule NameThe name you set
TriggerData Change / Schedule / Manual
ConditionText preview of the condition (e.g. temperature > 30)
ActionsList of actions in this rule (Notify / Execute / Trigger Agent)
Status ToggleEnable / disable switch
Actions MenuEdit, delete, execute now

The Import / Export button in the top right lets you bulk import/export rule JSON.

Rule Structure​

A rule has four parts β€” name, trigger, condition, and actions (optional duration and cooldown):

{
"name": "High Temperature Alert",
"trigger": { "trigger_type": "data_change" },
"condition": {
"condition_type": "comparison",
"source": "device:sensor-01:temperature",
"operator": "greater_than",
"threshold": 30
},
"actions": [
{ "type": "notify", "message": "Temperature too high: {value}Β°C", "severity": "critical" }
]
}

Creating a Rule via Web UI​

Step 1: Open the Rule Builder​

In the Rules tab, click the Create button to open the full-screen rule builder:

Rule builder β€” basic info area: name, description, trigger selector

Fill in the top of the builder:

FieldDescription
NameDisplay name for the rule
DescriptionOptional, explains the rule's purpose
TriggerSelect the trigger type (see below)

Step 2: Configure the Trigger​

Trigger TypeDescriptionUse Case
Data ChangeAuto-evaluates when referenced metrics have new dataReal-time alerts, threshold monitoring
ScheduleTriggers on a cron expressionScheduled reports, periodic checks
ManualOnly triggered manually (API / CLI / UI button)Debugging, on-demand execution

Cron uses 6-field format: sec min hour day month weekday. "0 */5 * * * *" = every 5 minutes.

The data_change trigger automatically extracts referenced data sources from the condition β€” no need to specify sources manually.

Step 3: Configure the Condition​

Rule builder β€” condition config area: select data source, operator, threshold

Conditions determine when a rule fires. Three types are supported:

Comparison condition β€” compares a value to a threshold:

OperatorMeaningThreshold Field
greater_thanGreater thanthreshold (number)
less_thanLess thanthreshold (number)
greater_equalGreater than or equalthreshold (number)
less_equalLess than or equalthreshold (number)
equalEqualthreshold (number/boolean)
not_equalNot equalthreshold
containsContains (string)threshold_value (string)
starts_withPrefix matchthreshold_value
ends_withSuffix matchthreshold_value
regexRegex matchthreshold_value

source uses DataSourceId format {type}:{id}:{field}, e.g. device:sensor-01:temperature.

Range condition β€” fires when value is within a range:

{ "condition_type": "range", "source": "device:sensor-01:temperature", "min": 20, "max": 25 }

Logical condition β€” AND / OR / NOT nesting multiple sub-conditions:

{
"condition_type": "logical",
"operator": "and",
"conditions": [
{ "condition_type": "comparison", "source": "device:sensor-01:temperature", "operator": "greater_than", "threshold": 30 },
{ "condition_type": "comparison", "source": "device:sensor-01:humidity", "operator": "less_than", "threshold": 20 }
]
}

Step 4: Configure Actions​

Rule builder β€” action config area: notify, execute command, trigger agent

Actions execute when the condition is met. A rule can have multiple actions, executed in order.

Actiontype valueDescription
Send notificationnotifyMessage template supports {value}, {source_id} interpolation
Execute commandexecuteSend control command to a device or extension
Trigger Agenttrigger_agentCall an AI Agent for deep analysis

notify action β€” severity values: info, warning, critical, emergency

{ "type": "notify", "message": "Temperature too high: {value}Β°C", "severity": "critical" }

execute action β€” send a device control command:

{ "type": "execute", "target": "humidifier-01", "target_type": "device", "command": "power_on", "params": { "level": 3 } }

trigger_agent action β€” call an AI Agent:

{ "type": "trigger_agent", "agent_id": "diagnostic", "input": "sensor-03 is offline, please diagnose" }

Step 5: Duration and Cooldown​

FieldDescription
For Duration (seconds)Condition must be continuously met for this duration before firing, filtering out sensor jitter
Cooldown (seconds)Minimum interval between triggers, default 60 seconds

Click Save to save the rule.

JSON Structure Reference​

Complete JSON field reference
{
"name": "Sustained High Temperature",
"trigger": { "trigger_type": "data_change" },
"condition": {
"condition_type": "comparison",
"source": "device:sensor-01:temperature",
"operator": "greater_than",
"threshold": 30
},
"actions": [
{ "type": "notify", "message": "Temperature above 30Β°C for 5 minutes", "severity": "critical" }
],
"for_duration": 300,
"cooldown": 60
}

Other Creation Methods​

CLI​

# Create a rule (JSON format)
neomind rule create --json '{"name":"High Temp","trigger":{"trigger_type":"data_change"},"condition":{"condition_type":"comparison","source":"device:sensor-01:temperature","operator":"greater_than","threshold":30},"actions":[{"type":"notify","message":"Too hot"}]}'

# List all rules
neomind rule list

# Enable / disable
neomind rule enable <rule_id>
neomind rule disable <rule_id>

# Execute rule immediately (manual trigger)
neomind rule test <rule_id> --execute

# Delete rule
neomind rule delete <rule_id>

REST API​

# Create rule (JSON body)
curl -X POST http://localhost:9375/api/rules \
-H "Content-Type: application/json" \
-d '{
"name": "High Temp",
"trigger": { "trigger_type": "data_change" },
"condition": { "condition_type": "comparison", "source": "device:sensor-01:temperature", "operator": "greater_than", "threshold": 30 },
"actions": [ { "type": "notify", "message": "Too hot" } ]
}'

# View execution history
curl http://localhost:9375/api/rules/<rule_id>/history

AI Chat​

Just tell AI Chat:

"Email me when the temperature goes above 30 degrees"

The LLM auto-generates and creates the rule.

Import / Export​

The Import / Export button in the Rules tab supports bulk management:

OperationDescription
ExportExport all rules to a JSON file (neomind-rules-YYYY-MM-DD.json)
ImportUpload a JSON file to bulk import rules, with incremental import (skips existing rules with the same name)

Rule Validation​

When creating a rule, NeoMind performs context-aware validation:

  • Device/extension exists
  • Metric name is valid
  • Command parameters match the device type definition
  • Agent ID exists (for trigger_agent actions)

Validation failures return detailed error messages listing which field has the problem.

Complete Examples​

1. Temperature & Humidity Combined Alert​

High temp + low humidity: notify and turn on humidifier:

{
"name": "Temp-Humidity Combo",
"trigger": { "trigger_type": "data_change" },
"condition": {
"condition_type": "logical",
"operator": "and",
"conditions": [
{ "condition_type": "comparison", "source": "device:sensor-01:temperature", "operator": "greater_than", "threshold": 30 },
{ "condition_type": "comparison", "source": "device:sensor-01:humidity", "operator": "less_than", "threshold": 20 }
]
},
"actions": [
{ "type": "notify", "message": "High temp low humidity: {value}Β°C", "severity": "critical" },
{ "type": "execute", "target": "humidifier-01", "target_type": "device", "command": "power_on", "params": { "level": 3 } }
]
}

2. Scheduled Energy Report​

Trigger Agent at 8 AM daily to summarize energy:

{
"name": "Daily Energy Report",
"trigger": { "trigger_type": "schedule", "cron": "0 0 8 * * *" },
"actions": [
{ "type": "trigger_agent", "agent_id": "energy-reporter", "input": "Summarize yesterday energy data and send report" }
]
}

3. Sustained Anomaly Triggers Agent​

Device offline for 10+ minutes triggers diagnostic Agent:

{
"name": "Device Offline Diagnosis",
"trigger": { "trigger_type": "data_change" },
"condition": { "condition_type": "comparison", "source": "device:sensor-03:online", "operator": "equal", "threshold": 0 },
"for_duration": 600,
"actions": [
{ "type": "notify", "message": "sensor-03 offline for 10 minutes", "severity": "critical" },
{ "type": "trigger_agent", "agent_id": "diagnostic", "input": "sensor-03 is offline, please diagnose" }
]
}

Execution History​

Click the actions menu on any rule row to view execution history:

  • Trigger time
  • Whether the condition was met
  • How many actions executed
  • Result of each action (success/failure/reason)
  • Evaluation duration

Integration with Other Modules​

ModuleDescription
Notificationsnotify action routes to configured notification channels
AI Agenttrigger_agent action calls an autonomous agent for deep analysis
Devicesexecute action sends device commands
Data TransformsRules can reference derived metrics from Transforms
AI ChatCreate rules in natural language, LLM auto-generates JSON

Best Practices​

  • Add for_duration for debounce: Sensor data is noisy; use "for_duration": 120 to filter transient spikes
  • Set cooldown to prevent spam: High-frequency data sources need cooldown to prevent alert storms
  • Tiered notifications: Regular alerts severity: "info", severe alerts severity: "critical"
  • Prefer rules over Agents: Deterministic logic uses rules (millisecond evaluation), fuzzy judgment uses Agents (seconds of LLM analysis)
  • Idempotent actions: Design device commands as idempotent (e.g. power_on safe to call repeatedly), preventing side effects from rule retries

Last updated: 2026-06-16