Blocks Explained Series
Analytics Builder comes with dozens of built-in blocks for every kind of task. There are input and output blocks, but more importantly there is a whole zoo of blocks that are meant to build business logic:
- calculations and aggregations,
- logic combinations,
- and blocks that help you define and manipulate the general data flow.
This series tries to guide you through the jungle of blocks by providing helpful descriptions and examples on some of the most commonly used blocks and their typical use cases.
In this article, we are going to have a look at the latch-value block.
Overview
The Latch block (apama.analyticskit.blocks.core.Latch) is a core component in Cumulocity Analytics Builder used to capture and hold the latest input value received while the block is enabled.
The block only produces an output when the input value changes and the block is enabled. This behavior helps eliminate duplicate processing and reduces unnecessary downstream events in analytics pipelines.
If the Enable input is connected, the block starts in a disabled state. If the Enable input is not connected, the block remains always enabled.
The Latch block is commonly used in IoT data processing models where telemetry streams may contain repeated values or where analytics should run only under certain conditions.
Key Behavior
The Latch block performs the following actions:
- Monitors an incoming value
- Stores the most recent value received while enabled
- Generates output only when the value changes
- Allows analytics logic to run conditionally when enabled
This makes it particularly useful for filtering repeated values, tracking state transitions, and controlling event flows.
Typical Data Flow
In many analytics pipelines, the Latch block is placed between a device measurement and downstream processing logic.
Example flow:
Device Measurement → Latch → Analytics Logic
This ensures that downstream components receive only meaningful value updates.
Use Cases
1. Last known temperature before machine stops
Device: Test Device (87147518985) — While the machine fan is running, the Latch block continuously tracks the temperature. The moment the fan stops, it freezes the last valid reading. This creates a permanent measurement snapshot: what was the temperature when the machine last stopped?
Model flow
Actual Model
2. Peak gas concentration during active alarm
Device: 81147640904 (c8y_gasMonitor) — When a gas danger alarm fires, the Latch block becomes enabled and tracks gas concentration throughout the alarm period. Each updated reading is written to a measurement series, building an incident log that shows how gas levels evolved during the alarm event.
Model flow
Actual Model
When to Use the Latch Block
Use the Latch block when:
- You want to process only changed values
- You need to filter repeated telemetry
- Analytics should run only under certain conditions
- You are tracking state transitions
Key difference from Gate block
The Gate block passes or blocks a signal in real time. The Latch block remembers the last value seen while active — it’s about state preservation, not signal gating. Use Latch when you need to answer “what was the reading at a specific point in time?”
Summary
The Latch block is a simple yet powerful component in Cumulocity Analytics Builder that enables efficient data flow control.
By allowing outputs only when values change and when the block is enabled, it helps:
- Reduce duplicate events
- Improve analytics performance
- Control processing based on system state
- Simplify event-driven logic in IoT pipelines
The block is widely used in industrial IoT monitoring, state tracking, alarm management, and telemetry optimization scenarios.




