Predict Remaining Time
Predict remaining time answers the question: how long until a telemetry value reaches a critical threshold? Instead of reacting after the event occurs, you get a live countdown that you can display, trend over time, and attach alarm rules to.
Telemetry history ────────────────────────────────────────────────── ●──●──●──●──●──●──● ← historical values ↓ trained prediction model ●──●──●──●──●──● ← forecast ↑ threshold crossing │ ← remaining ─┘ timeThe approach combines two Trendz features:
- A Prediction Model that extends your telemetry into the future.
- A Batch Calculated Field that scans the forecast, finds the first crossing of your threshold, and returns the time distance from now to that crossing point.
The resulting countdown value is written back to ThingsBoard as a regular telemetry key, so it works with alarms, dashboards, and widgets — no special integration required. If the threshold is not crossed within the prediction range, nothing is written and any previously stored countdown value is left unchanged.
Multiple thresholds on the same entity (e.g. low reserve and critical reserve) are supported by creating one countdown calculation field per threshold.
Use cases
Section titled “Use cases”| Scenario | Telemetry | Threshold | Direction |
|---|---|---|---|
| Fuel depletion | Tank level (%) | Reserve level, e.g. 10% | Drops below (≤) |
| Battery discharge | Battery charge (%) | Minimum, e.g. 5% | Drops below (≤) |
| Energy limit | Cumulative consumption (kWh) | Monthly quota | Exceeds (≥) |
| Pressure overload | Boiler pressure (bar) | Safety limit | Exceeds (≥) |
| Time-to-Maintenance | Operating hours or vibration level | Maintenance threshold | Exceeds (≥) |
| Storage capacity | Used storage (GB) | Capacity limit | Exceeds (≥) |
| Temperature runaway | Sensor temperature (°C) | Critical temperature | Exceeds (≥) |
How it works
Section titled “How it works” Step 1 — Prediction model ───────────────────────────────────────────────── historical telemetry │ ▼ train ML model (ARIMA / Holt-Winters / custom Python) │ ▼ generate future data points → stored in ThingsBoard under _EPD_… key
Step 2 — Countdown field (Batch CF) ───────────────────────────────────────────────── future data points │ ▼ scan forward in time first point where value crosses threshold │ ▼ compute distance from now → that timestamp │ ▼ write countdown value → stored in ThingsBoard under _ECD_… key
Step 3 — Alarm rule (ThingsBoard) ───────────────────────────────────────────────── countdown ≤ alert horizon → alarm created countdown > alert horizon → alarm clearedThe countdown value decreases over time. When it drops below your chosen alert horizon (e.g. 3 days), ThingsBoard fires an alarm so you can take action before the event occurs.
Implementation guide
Section titled “Implementation guide”For full step-by-step instructions — building the prediction model, writing the batch script, enabling the field, and configuring alarm rules — see:
Calculate Time to Event