Overview
Actions are executable logic blocks that run directly inside the Coreflux MQTT broker. They react to events—incoming messages, time intervals, or manual triggers—and perform operations like data transformation, routing, and alerting.Action Capabilities
| Capability | Description |
|---|---|
| Event-Driven Execution | Trigger on MQTT messages with wildcard support for flexible topic matching |
| Time-Based Scheduling | Execute at regular intervals—seconds to weeks—for monitoring and reporting |
| Data Transformation | Extract JSON fields, perform calculations, and restructure payloads inline |
| Conditional Logic | Route data, set thresholds, and make decisions with IF/THEN/ELSE |
When to Use Each Pattern
| Pattern | Use When |
|---|---|
Time-Based (ON EVERY) | Periodic tasks: heartbeats, polling, scheduled reports |
Topic-Based (ON TOPIC) | Event-driven processing: sensor data, commands, alerts |
| Callable (no trigger) | Reusable utilities invoked by other actions or commands |
Python-Extended (CALL PYTHON) | Complex calculations, external libraries, data validation |
In This Section
Syntax Reference
Start here to learn the DEFINE ACTION structure and build your first action.
Action Triggers
Choose the right trigger type for your use case: time-based, topic-based, or callable.
Operations
Master SET, GET, PUBLISH, conditionals, and all available LoT operations.
Python Integration
Extend actions with Python when you need complex logic or external libraries.
Action Types
LoT supports three action patterns:Time-Based Actions
Execute at regular intervals usingON EVERY:
- Runs on a schedule regardless of incoming data
- Useful for monitoring, polling, and periodic reports
- Supported units: SECONDS, MINUTES, HOURS, DAYS, WEEKS
Topic-Based Actions
Execute when MQTT messages arrive usingON TOPIC:
- Triggers instantly when matching messages arrive
- Supports
+(single-level) and#(multi-level) MQTT wildcards - Access payload data via
PAYLOADandGET JSON - Extract topic segments with
TOPIC POSITION
Callable Actions
Actions without triggers are invoked manually or by other actions:- No automatic trigger—must be invoked explicitly
- Can accept input parameters and return values
- Invoked via
$SYS/Coreflux/CommandorCALL ACTION - Ideal for reusable utility functions
Learn more about invoking callable actions in Action Triggers.
Core Operations
Actions use these operations to process data:SET, GET TOPIC, GET JSON, PUBLISH, and IF/THEN are the core operations for working with data in actions. See the Operations Reference for complete details.
- Variables
- Topic Operations
- JSON Extraction
- Conditionals
Create and use variables within an action:
Example: Complete Sensor Processor
This example combines topic matching, JSON extraction, conditional routing, and state updates in a realistic sensor processing action.- Triggers when any message arrives at
sensors/*/raw - Extracts the sensor ID from the topic path
- Parses temperature and humidity from the JSON payload
- Routes alerts based on temperature thresholds
- Publishes processed data and timestamps
Actions vs. Models
Actions and Models serve different purposes in LoT:| Aspect | Actions | Models |
|---|---|---|
| Purpose | Process and route data | Structure and format data |
| Execution | Event-driven logic | Schema definition |
| Output | Any MQTT operation | Structured JSON |
| Complexity | Conditionals, loops, Python | Field mapping, calculations |
| Best For | Routing, alerting, transformation | Data aggregation, formatting |

