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" }
]
}
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": 300000,
"cooldown": 60000
}

Other Creation Methods

Option 1: 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 DurationCondition must be continuously met for this duration before firing, filtering out sensor jitter. The JSON field is in milliseconds (e.g. 5 minutes = 300000; the UI offers seconds / minutes / hours)
CooldownMinimum interval between triggers. The JSON field is in milliseconds, default 60000 (60 seconds)

Click Save to save the rule.

CLI

# Create a rule (JSON format)
neomind rule create --body '{"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>

# Dry-run rule evaluation (only evaluates whether the condition is met, without triggering actions)
neomind rule test <rule_id> --input '{"temperature": 35}'

# 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; rules that fail to import (e.g. invalid format) are counted as "skipped" and reported in the result

Rule Validation

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

  • Referenced device exists
  • Metric name is valid
  • Command parameters match the device type definition
  • Extension and Agent IDs are checked to be non-empty

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": 600000,
"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
Data PushRules evaluate data in-platform and trigger actions; Data Push sends data off-platform
AI ChatCreate rules in natural language, LLM auto-generates JSON

Best Practices

  • Add for_duration for debounce: Sensor data is noisy; use "for_duration": 120000 (2 minutes) to filter transient spikes (unit is milliseconds)
  • 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

Next Steps

  • Data Push — Send in-platform data to external systems in real time
  • Notifications — Configure channels and filters for notify actions
  • AI Agent — Use trigger_agent actions for deep Agent analysis

Last updated: 2026-09-09