Skip to main content
Actions are executable logic blocks triggered by events such as timed intervals, topic updates, or explicit calls. They are the primary way to implement automation in LoT.
Actions run inside the MQTT broker itself, eliminating the need for external middleware or application servers.

Basic Syntax

Components

string
required
A unique identifier for the action. Use descriptive names that indicate the action’s purpose (e.g., SensorDataProcessor, HeartbeatMonitor).
trigger
required
Specifies when the action executes. Can be time-based (ON EVERY, ON TIMESTAMP), topic-based (ON TOPIC, ON CHANGE), initialization (ON START), client lifecycle (ON CONNECT, ON DISCONNECT, ON SUBSCRIBE), or omitted for callable actions.
statements
required
One or more LoT statements that execute when the action triggers. These can include publishing, variable assignment, conditionals, and Python calls.

Action Structure

Every action follows this general structure:

Disable an Action

Add DISABLE true on its own line to switch an action off without deleting it:
A disabled action stays defined and listed, but no trigger runs it: topics, ON EVERY, schedules, ON START, and client connect, disconnect, or subscribe. -runAction refuses it, and an action that calls it with CALL ACTION fails to compile until it is enabled again. DISABLE false, or no DISABLE line, means enabled. A DISABLE line inside a comment is ignored. The line is saved with the definition, so the action stays disabled after a restart and in a project export. To switch it without editing the code, use -disableAction <name> and -enableAction <name>. See Disable and enable.

Trigger Types

Execute at regular intervals:
Supported units: SECOND(S), MINUTE(S), HOUR(S), DAY(S), WEEK(S)

Compatible Keywords

Keywords that can be used within action logic:

Variable Operations

Topic Operations

KEEP TOPIC is different: it stores a value for GET TOPIC in the broker cache and does not set the MQTT retain flag. KEEP does not accept RETAIN (use PUBLISH TOPIC ... RETAIN when new subscribers must receive the last payload). RETAIN and a QoS keyword can appear in either order (RETAIN QOS1 or QOS1 RETAIN). Each PUBLISH TOPIC and each KEEP TOPIC in one run is sent in the order it is written, including several writes to the same topic. Full actions are in ACTION Operations.

Control Flow

Entities

Python Integration

Extend LoT with Python: Use CALL PYTHON to execute complex calculations, data validation, or integrate external libraries. See the Python Integration guide for complete syntax and examples.

Type Casting

Use AS to cast values when performing comparisons or calculations:
Supported types: STRING, INT, DOUBLE, FLOAT (alias SINGLE, for protobuf float), BOOL, TIMESTAMP, BYTES For binary MQTT payloads you want to forward unchanged (protobuf, Modbus frames, image chunks), use PAYLOAD AS BYTES with PUBLISH TOPIC or KEEP TOPIC. See Binary passthrough. To read or write protobuf fields, use GET PROTO and PUBLISH MODEL — see Protobuf Models.

Complete Example

Putting It All Together: This example demonstrates topic extraction, JSON parsing, conditional logic, and publishing - the core patterns you’ll use in most actions.

Next Steps

Action Triggers

Learn about time-based, topic-based, and client lifecycle triggers in detail.

Operations

Master GET, SET, PUBLISH, and conditional logic.
Last modified on October 25, 2026