Use Metrics in ThingsBoard
Metrics created in the Trendz Metric Explorer can be published to ThingsBoard as telemetry and used anywhere ThingsBoard supports telemetry — dashboards, Rule Engine, and Alarm Rules.
Generated Metric │ │ Save Calculation ▼ Native Calculation Field │ ├── Reprocess Task ──▶ Historical data saved to ThingsBoard │ └── Refresh Task ────▶ Ongoing automatic updates │ ▼ ThingsBoard Telemetry (key: _ECD_*) │ ┌───────────────┼───────────────┐ ▼ ▼ ▼ Dashboards Alarm Rules Rule EngineSave to ThingsBoard
Section titled “Save to ThingsBoard”Create Calculation Field
Section titled “Create Calculation Field”From the Generated Metric editor, click Save Calculation and enter:
| Parameter | Description |
|---|---|
| Calculation Name | Label shown in Trendz for this field. |
| Calculation Key | Telemetry key used in ThingsBoard, automatically prefixed with _ECD_. |
Example: saving key energy_consumption_rate creates ThingsBoard telemetry at
_ECD_energy_consumption_rate.
Click Save — the field appears in the Calculation folder in the Fields Section.
Before running any jobs, verify the following parameters on the Calculation Field:
| Parameter | Description |
|---|---|
| Grouping Interval | How data is bucketed — e.g., HOUR saves one point per hour to ThingsBoard. |
| Aggregation | How multiple values in the same interval are combined — e.g., SUM. |
| Time | The lookback window used by the refresh job. |
Recommended Time settings by job frequency:
| Time setting | Use when |
|---|---|
| Today | Minute or hourly jobs |
| Last 7 Days | Daily jobs |
| Last 14 Days | Weekly jobs |
| Last 3 Months | Monthly jobs |
Click Save Field, then confirm with Save to apply the parameters.
Run Reprocess Task
Section titled “Run Reprocess Task”A Reprocess Task calculates the metric over a historical time range and saves the results to ThingsBoard. Run this once after creating the Calculation Field to populate historical data.
-
Open the Tasks tab.
-
Click Run Reprocess Task.
-
Select the time range to reprocess.
-
Choose the items — you can apply the job to the current item, all items, or a subset of items with the same entity profile.
-
Click Run.
After the task completes, ThingsBoard will contain telemetry points for the selected period.
Run Refresh Task
Section titled “Run Refresh Task”A Refresh Task keeps telemetry up to date by automatically recalculating the metric on a schedule.
-
Click the Jobs button.
-
Enable calculation result saving.
-
Set the start date — the date from which new data will be saved.
-
Define the frequency — how often the job runs.
-
Choose the target items — entities with the same entity profile to update automatically.
-
Click Save.
Once saved, the Enabled status appears next to the calculation name. Telemetry will now update automatically at the configured frequency for the selected items.
Use in ThingsBoard
Section titled “Use in ThingsBoard”Once the Calculation Field is configured with a refresh job and historical data is loaded via a
reprocess job, the metric telemetry is continuously updated in ThingsBoard. You can use it anywhere
ThingsBoard supports telemetry — including dashboards, Alarm Rules, and the Rule Engine. The metric
telemetry key (e.g., _ECD_energy_consumption_rate) is used in Rule Engine chains exactly like any
other device telemetry key.
Alarm Rules
Section titled “Alarm Rules”Create ThingsBoard alarms triggered by the metric telemetry:
-
Open the entity profile where the calculation is applied.
-
Navigate to Alarm Rules and enable Edit mode.
-
Click Add alarm rule and configure the create and clear conditions.
-
Click Apply changes.
Example: A metric calculates the absolute temperature deviation from the building average. An alarm rule triggers a Warning alarm of type Abnormal Temperature when the deviation exceeds 10, and clears it when it drops back below. This can detect device overheating, an open window, or a broken refrigerator — without writing any Rule Engine logic.
Trendz Visualizations
Section titled “Trendz Visualizations”Visualize the metric using any Trendz widget — line chart, heatmap, state chart (from the Range Analysis tab), and more. Completed views can be embedded into ThingsBoard dashboards.
See Trendz Visualizations and Embed Visuals in ThingsBoard for details.
Predict Future Values
Section titled “Predict Future Values”Use Trendz Prediction Models to forecast future values of the metric and embed the prediction view into a ThingsBoard dashboard.
See Prediction Models for details.
Detect Anomalies
Section titled “Detect Anomalies”Use Trendz Anomaly Models to detect anomalies or outages in the metric. When an anomaly is detected, automatic alarm creation can be configured.
See Anomaly Detection for details.