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
Define fields with specific types (STRING, INT, DOUBLE, BOOL, OBJECT, ARRAY) to create consistent data schemas.
Auto JSON Handling
Automatically explode incoming JSON payloads into individual topics for easy field access.
Data Aggregation
Combine data from multiple MQTT topics into a single structured output.
Calculations
Perform inline calculations and conditional logic to derive new values.
How Models Work
Models receive data, structure it according to your schema, and publish it as JSON. Understanding this flow is essential before diving into the different model types.Receiving JSON Payloads
All models automatically handle incoming JSON payloads by “exploding” them into individual topics. This makes each field accessible for other models and actions: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 a model triggers (either automatically or via action), it publishes structured JSON combining all its fields: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:

