Skip to content

Rule Engines (Developer) ​

Type rule_engine rows in rule_chains, bound via device_profiles.rule_engine_id. Optional tenant default_rule_engine_id (migration 0030) when the profile has no engine.

Ingest order ​

rule engine → persist / realtime / profile Alarm Rules

Data/attribute pipelines and calculated-fields stages are removed from the product path. Transforms belong in Rule Engine nodes.

API ​

  • GET/POST/PATCH/DELETE /api/rule-engines
  • POST /api/rule-engines/:id/start|pause
  • POST /api/rule-engines/preview
  • GET /api/rule-engines/:id/debug-traces
  • GET /api/rule-engines/:id/metrics
  • Tenant default: related fields on tenant / rule-engines APIs as exposed

Runtime ​

  • RuleEngineExecutorService.applyForDevice on the ingest path
  • Filter supports compound conditions + optional json-rules-engine engineRules
  • Nodes: delay, switch, notify, dedupe, math (+ - * / and abs, min, max, round, floor, ceil, sqrt, pow on numeric keys), rest_call, engine_ref, related_entity, integration_downlink, …
  • Message types: telemetry, attributes, device_inactive, device_active, rpc_response
  • Webhook defaults to async (off critical path); set async: false to await
  • Debug traces + rolling metrics (0029_rule_engine_debug.sql)
  • Script metadata.messageType is telemetry, attributes, device_inactive, device_active, or rpc_response
  • Dedupe, throttle, create-alarm cooldown, and filter hysteresis are stored in Presence Redis (ruleeng:state:) with a TTL when Redis is up, and also kept in process memory. If Redis is down, that state does not survive a restart or a second API process. Delay jobs already use Redis the same way.
  • Kill switch: RULE_ENGINE_ENABLED

Messaging ​

  • MessagingService prefers Telegram (TELEGRAM_BOT_TOKEN); Brevo SMS optional fallback
  • Alarm tenant group: tenants.telegram_chat_id via PATCH /api/alarms/escalation-settings (telegramChatId)
  • Rule Engine notify supports emails, phones, telegramChatIds

UI ​

  • React Flow editor at /rule-engines
  • Feature: frontend/src/features/rule-engines
  • Dependency: @xyflow/react, backend json-rules-engine
  • Legacy /data-pipelines and /attribute-pipelines redirect here

support@autoconnecto.in · founder@autoconnecto.in · +91 92121 00555 · app.autoconnecto.in