Skip to content
Stand with Ukraine flag

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 ─┘
time

The approach combines two Trendz features:

  1. A Prediction Model that extends your telemetry into the future.
  2. 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.

ScenarioTelemetryThresholdDirection
Fuel depletionTank level (%)Reserve level, e.g. 10%Drops below (≤)
Battery dischargeBattery charge (%)Minimum, e.g. 5%Drops below (≤)
Energy limitCumulative consumption (kWh)Monthly quotaExceeds (≥)
Pressure overloadBoiler pressure (bar)Safety limitExceeds (≥)
Time-to-MaintenanceOperating hours or vibration levelMaintenance thresholdExceeds (≥)
Storage capacityUsed storage (GB)Capacity limitExceeds (≥)
Temperature runawaySensor temperature (°C)Critical temperatureExceeds (≥)
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 cleared

The 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.

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