What are Models?
Models in LoT are like database schemas for MQTT data. They define the structure of your data, ensure consistency across your system, and provide automatic JSON formatting.Model Capabilities
Data Structuring
Data Structuring
Define fields with specific types (STRING, INT, DOUBLE, BOOL, ARRAY) to create consistent data schemas.
Auto JSON Handling
Auto JSON Handling
Automatically explode incoming JSON payloads into individual topics for easy field access.
Data Aggregation
Data Aggregation
Combine data from multiple MQTT topics into a single structured output.
Calculations
Calculations
Perform inline calculations and conditional logic to derive new values.
How Models Work
Models do more than format data. They aggregate values from multiple MQTT topics, scale across device fleets with wildcards, compute derived metrics inline, and apply conditional logic — all within the broker, with zero external code. Here’s how the core flow works.Receiving JSON Payloads
When a device sends a full telemetry payload, you often need to access individual fields independently — for threshold alerts, dashboard widgets, or other models. All models automatically handle this by “exploding” incoming JSON payloads into individual topics:sensors/device1/data:
sensors/device1/data/temperature→23.5sensors/device1/data/humidity→65sensors/device1/data/status→"active"
This “explosion” behavior allows you to subscribe to individual fields or use them in other models and actions.
Producing Structured Output
When downstream systems — databases, dashboards, REST APIs — expect a specific JSON schema, a model guarantees that format on every publish. When a model triggers (either automatically or via action), it publishes structured JSON combining all its fields:Aggregating Multiple Sources
When you need a unified equipment dashboard from scattered PLC topics, or a combined production report from sensors across different lines, a single model pulls live values from many independent topics and merges them into one structured output — replacing external aggregation scripts or middleware entirely. Each field draws from a different source topic, but the model waits for the trigger field (status) to update before publishing a combined snapshot:
Building Nested Objects with Indentation
When your API or database expects grouped fields — such as ametadata object inside a sensor reading, or a status block with nested maintenance details — use the OBJECT type to produce nested JSON directly. Fields indented one level deeper than ADD OBJECT become properties of that sub-object — the same way ADD fields under DEFINE MODEL become top-level properties.
ADD OBJECT (like "timestamp" above) return to the parent object.
What Else Can Models Do?
The examples above cover the fundamentals, but models go much further:- Nested Objects — Use the
OBJECTtype with indentation to group related fields into sub-objects, producing clean nested JSON hierarchies. See examples → - Wildcard Models — Define one model with
+wildcards and it automatically handles every matching device. One definition, hundreds of instances, zero duplication. See examples → - Inline Calculations — Compute efficiency percentages, unit conversions, and running averages directly inside the model definition — no external processing needed. See examples →
- Conditional Logic — Dynamically tag field values based on live data: label readings as
"HIGH"or"NORMAL", flag quality as"PASS"or"FAIL", assign priority levels. - Action-Published Templates — Use
COLLAPSEDmodels as reusable schemas, then publish them from actions with full control over timing, routing, and conditional decisions. Learn more →
Model Types
LoT supports three model patterns, each suited for different scenarios:| Pattern | Use When |
|---|---|
| Basic Model | You want automatic triggering on data changes |
| Template Model (COLLAPSED) | You need control over when and where data is created |
| Inheritance (FROM) | You have related data types sharing common fields |
Basic Models
Basic models automatically trigger and publish structured data when their trigger field updates:WITH TOPICspecifies where output is publishedAS TRIGGERdefines which field change causes publication- Runs automatically when trigger field updates
Template Models (COLLAPSED)
Template models are reusable schemas for dynamic data creation from within actions. TheCOLLAPSED keyword indicates they have no automatic trigger:
COLLAPSEDmeans no automatic trigger- Published explicitly with
PUBLISH MODEL - Full control over when and where data is created
Learn how to publish template models from actions in Publishing Models.
Model Inheritance (FROM)
Create model families with shared fields using theFROM keyword:
- Child models inherit all parent fields
- Add specialized fields as needed
- Promotes code reuse and consistency
Learn more about designing model hierarchies in Model Inheritance.
Data Sources
Model fields can be populated from various sources:- Static Values
- Topic Data
- Timestamps
- Calculations
- Conditionals
Use static values for constants like units, default thresholds, or fixed identifiers that never change:
Next Steps
Model Syntax
Learn the complete syntax for defining model fields and triggers.
Model Inheritance
Create model families with shared fields using FROM.

