Skip to main content

Examples Index

Find the right pattern for your use case:

Basic Model Examples

Simple Sensor Reading

A straightforward model that formats raw sensor data with static metadata. This model adds context (sensor ID, unit, status) to a raw temperature value:
When a value arrives at sensors/raw/temperature, the model publishes:

Multi-Source Equipment Status

Combine data from multiple topics into a unified equipment status report. Each field pulls from a different source topic. The status topic acts as the trigger:
When the status topic updates, the model publishes a combined report to equipment/status/formatted:

Production Record with Calculations

Automatically calculate derived values like efficiency percentages. The efficiency_percent field is calculated inline from other topic values:
Example output when 95 of 100 units are produced:

Wildcard Model Examples

Multi-Instance Sensor Model

Handle multiple sensors with a single model definition using the + wildcard. The + wildcard matches any single level in the topic hierarchy:
When sensors/temp001/value receives data, the model publishes to sensors/temp001/formatted:
Each sensor instance (temp001, pressure002, etc.) gets its own output topic automatically. The wildcard maintains topic context through the model.

Factory Hierarchy Model

Handle multi-level topic hierarchies with multiple wildcards. Multiple + wildcards capture different levels of the hierarchy:
When factory/line1/machine1/status updates, the model publishes to factory/line1/machine1/data/formatted:

Models Published by Actions Examples

Use this pattern when you need full control over publishing logic—conditional decisions, complex calculations, JSON extraction, or custom routing. The action determines when and where to publish.

Alarm Record from JSON

Process incoming JSON payloads into structured alarm records. First, define the model schema with COLLAPSED (no automatic trigger):
Then create an action that extracts JSON fields and publishes the model:
When a JSON payload arrives at alarms/pump003/json_input, the action publishes to alarms/structured/pump003:

Production Event with Calculations

Create production records with computed metrics like efficiency. Define the schema for production events:
The action performs calculations before publishing:
When a production event arrives at production/line2/events with a target cycle time of 10s and an actual cycle time of 8.5s, the action publishes to production/events/structured/line2:

Quality Check with Validation

Determine pass/fail status based on measurement tolerances.
Complex conditional logic (like tolerance checking) is cleaner in an action than inline in a model. The action can also route to different topics based on the result.
Define the quality reading schema:
The action checks if the measurement is within tolerance and routes accordingly:
When a measurement of 10.02 mm arrives for a part with a target of 10.00 mm and tolerance of 0.05 mm, it passes and publishes to quality/passed/PART_A1:

Model Inheritance Examples

For complete inheritance patterns and syntax, see Model Inheritance.

Alert Model Family

Create specialized alert types from a common base model. First, define the base model with common fields:
Then create specialized models that inherit and extend it:
Use the specialized model in an action:
When an alert triggers for sensor TH_042, the action publishes to alerts/temperature/TH_042 with both inherited and specialized fields:

Nested Object Examples

Sensor with Metadata

Group related configuration and context fields into nested sub-objects using the OBJECT type and indentation. The metadata field uses OBJECT to group location details into a nested object. Fields indented under ADD OBJECT become its properties. When indentation returns to the parent level, fields belong to the top-level model again:
When sensors/temp001/value receives data, the model publishes to sensors/temp001/formatted:
The indentation rule applies everywhere OBJECT is used — in basic models, wildcard models, and COLLAPSED templates published from actions.

Choosing the Right Pattern

Use when: Data flows continuously and formatting is straightforward.Best for: Sensor readings, status updates, simple aggregation.Trigger: Automatic when source topic updates.
Use when: You need derived metrics computed from source values.Best for: Percentages, totals, averages, unit conversions.Note: Keep calculations simple; use actions for complex logic.
Use when: You have multiple instances of the same data structure.Best for: Fleets of sensors, multi-line factories, device groups.Benefit: One model definition handles all instances.
Use when: You need control over timing, routing, or complex logic.Best for: JSON extraction, conditional publishing, pass/fail routing, complex calculations.Benefit: Full action power with structured output.
Use when: You have related data types sharing common fields.Best for: Alert families, equipment types, event categories.Benefit: DRY principle—define common fields once.
Use when: Your JSON output needs grouped or hierarchical data.Best for: Metadata grouping, configuration objects, multi-level status reports.Benefit: Clean nested JSON without external formatting. Indentation controls structure.

Next Steps

Routes Overview

Connect your broker to external systems and databases.

Actions Syntax

Master the action syntax for publishing models.
Last modified on May 22, 2026