Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt

Use this file to discover all available pages before exploring further.

What is LoT?

LoT (Language of Things) is a human-readable language for IoT automation. It uses near-English syntax to define logic, data structures, and integrations—all executed directly within the Coreflux MQTT broker. Everything in LoT is built by defining four types of entities — Actions, Models, Routes, and Rules. Each one handles a different part of your automation, and inside them you use commands like PUBLISH, SET, and GET to make things happen.
Think of LoT as SQL for real-time MQTT data. Just as SQL transforms database records, LoT transforms live MQTT streams.
Like building with LEGO blocks. You pick the right block for the job — Actions for logic, Models for data structure, Routes for connections, Rules for security — and snap them together into a complete system.

The Four Building Blocks

Everything in LoT is built from four core constructs, each created with the DEFINE keyword:
ConstructPurposeTrigger Types
ActionsExecute logic when events occurTime, Topic, System events, Manual
ModelsStructure MQTT data into JSON schemasTopic values, Action calls
RoutesConnect to external systemsTopic patterns
RulesControl who can publish/subscribeClient identity, Topic patterns

Actions

Event-driven logic triggered by time or MQTT topics.

Models

Data schemas that structure MQTT messages into JSON.

Rules

Access control for topics and operations.

Routes

Connect to databases, brokers, and external services.

How They Work Together

A typical LoT solution combines all four building blocks. Each definition below uses valid LoT syntax — the same patterns you will see in the Models, Actions, Routes, and Rules references.
-- 1. MODEL: When raw temperature updates, publish structured JSON per sensor
DEFINE MODEL SensorReading WITH TOPIC "sensors/+/formatted"
    ADD STRING "sensor_id" WITH TOPIC "sensors/+/id"
    ADD DOUBLE "temperature" WITH TOPIC "sensors/+/raw" AS TRIGGER
    ADD STRING "unit" WITH "celsius"
    ADD STRING "timestamp" WITH TIMESTAMP "UTC"

-- 2. ACTION: React to formatted readings and raise alerts
DEFINE ACTION TemperatureAlert
ON TOPIC "sensors/+/formatted" DO
    SET "sensor_id" WITH TOPIC POSITION 2
    SET "temp" WITH (GET JSON "temperature" IN PAYLOAD AS DOUBLE)
    IF {temp} > 80 THEN
        PUBLISH TOPIC "alerts/" + {sensor_id} + "/high_temp" WITH "Temperature above threshold"

-- 3. ROUTE: Persist sensor traffic to PostgreSQL
DEFINE ROUTE SensorDB WITH TYPE POSTGRESQL
    ADD SQL_CONFIG
        WITH SERVER "postgres.example.com"
        WITH PORT '5432'
        WITH DATABASE "iot_data"
        WITH USERNAME "iot_user"
        WITH PASSWORD "secure_password"
    ADD EVENT StoreSensorData
        WITH SOURCE_TOPIC "sensors/#"
        WITH QUERY "INSERT INTO sensor_readings (topic, payload) VALUES ('{topic}', '{value.json}')"

-- 4. RULE: Only trusted clients may publish to alert topics
DEFINE RULE RestrictAlertPublish WITH PRIORITY 10 FOR Publish TO TOPIC "alerts/#"
    IF USER HAS AllowedSystemAlerts OR USER IS "root" THEN
        ALLOW
    ELSE
        DENY
StepWhat Happens
1When sensors/temp001/raw updates, the Model publishes JSON to sensors/temp001/formatted
2The Action reads temperature from that JSON and publishes to alerts/temp001/high_temp when it exceeds 80
3The Route inserts every message under sensors/# (raw, formatted, and related topics) into PostgreSQL
4The Rule denies publish to alerts/# unless the client has AllowedSystemAlerts or is root

What You’ll Learn on This Page

Below you’ll find practical examples showing LoT in action - from simple heartbeats to data transformation. Each example demonstrates a core capability you can implement immediately.

Hello World

Three examples showing what LoT can do:
DEFINE ACTION Heartbeat
ON EVERY 5 SECONDS DO
    PUBLISH TOPIC "system/alive" WITH "ok"
ExampleTriggerWhat it does
HeartbeatEvery 5 secondsPublishes “ok” to indicate the system is alive
EchoMessage on input/messageForwards the payload to another topic
SensorDataValue on sensors/rawFormats raw sensor data into structured JSON

Next Steps

Best Practices & Patterns

Naming, topic design, reusable logic, and pitfalls to avoid.

Actions Overview

Learn how Actions automate MQTT data processing.
Last modified on May 20, 2026