Skip to content
Stand with Ukraine flag

Anomaly Detection in Heat Pumps

Detecting anomalies in heat pumps is essential to maintain their performance and avoid expensive repairs. Identifying unusual patterns in power usage, compressor speed, airflow, coolant pressure, and temperature lets you catch issues before they escalate into costly failures. Common problems include low coolant levels, blocked air filters, faulty compressors, and overheating.

Task definition: Detect anomalies in heat pumps in real time and notify the maintenance team about potential problems.

  • Create an anomaly detection model for heat pumps using historical telemetry data.
  • Configure automated anomaly discovery on real-time telemetry data.
  • Create a table widget to review all detected anomalies.
  • Save the anomaly score as device telemetry so ThingsBoard alarms can use it.
  • Notify the maintenance team when an anomaly is detected.

Heat pumps report telemetry to ThingsBoard via MQTT and are registered as device entities. Devices have a relation to an Apartment asset, and apartments are assigned to customer accounts. For this guide, each heat pump reports the following telemetry keys: compressorSpeed, airflow, coolantPressure, coolantTemperature, powerUsageWh.

Trendz uses unsupervised machine learning to detect anomalies in time series data. Train the model on historical data to establish what normal heat pump behavior looks like.

  1. Go to the Anomalies page and click Create model.
  2. Set the model name to HeatPumpAnomalyModel.
  3. Configure the model properties:
    • Cluster algorithm: K-Means
    • Segment time range: 1 hour — detect abnormal behavior within a 1-hour window
    • Comparison type: Behavior based — detect anomalies based on overall behavioral patterns
  4. Configure the datasource:
    • Time range: Last 90 days
    • Fields: heatPump.compressorSpeed, heatPump.airflow, heatPump.coolantPressure, heatPump.coolantTemperature, heatPump.powerUsageWh
    • Filters: leave blank to include all heat pumps
  5. Click Build model.

Once the model is trained, Trendz shows historical anomalies it discovered. Each anomaly has a score and a score index — higher values mean the behavior is more abnormal.

Configure a background job so Trendz continuously analyzes fresh telemetry and detects new anomalies.

  1. On the model summary page, click Auto discovery.
  2. Enable the Auto discovery checkbox.
  3. Set Interval to 1 hour.
  4. Click Apply.

Trendz will now periodically fetch new data from heat pumps, identify anomalies, compute anomaly scores, and save them to the database.

Create a view that shows both historical anomalies (discovered during model training) and new ones detected by the autodiscovery job.

  1. Create an Anomaly view.
  2. Select the model created in Step 1 — HeatPumpAnomalyModel.
  3. Add the heatPump field to the Filter section to focus on a specific device.
  4. Click Build report and review the discovered anomalies.
  5. Set the view name to heat pump anomalies table.
  6. Click Save.

To trigger ThingsBoard alarms from anomaly data, save the anomaly score as device telemetry, then create an alarm rule that fires when the score exceeds a threshold.

Save the anomaly score as telemetry

  1. Create a Table view in Trendz.
  2. Add the heatPump field to the Columns section.
  3. Add the Date FULL_HOUR field to the Columns section.
  4. Add an Anomaly field to the Columns section:
    • Model: HeatPumpAnomalyModel
    • Anomaly field: score index
    • Aggregation: MAX
    • Label: heatpumpAnomalyScore — Trendz saves this as a telemetry key
  5. Add the heatPump field to the Filters section.
  6. Open view settings → Tb calculated telemetry save section:
    • Enabled: true
    • Interval: 1
    • Unit: hours
  7. In View mode fields, set heatPump as the Row click entity — this determines under which device entity the telemetry is saved.
  8. Set the default time range to Last 7 days.
  9. Save the view as Heatpump anomaly score save job.

Trendz now runs a background job that periodically computes the anomaly score and saves it as telemetry on each heat pump device.

Create an alarm rule for anomaly score > 50

  1. In ThingsBoard, open the heat pump’s device profile and add a new Alarm Rule.
  2. Alarm type: Abnormal behavior
  3. Create alarm condition:
    • Severity: Warning
    • Condition: heatpumpAnomalyScore is greater than 50
  4. Clear alarm condition:
    • Condition: heatpumpAnomalyScore is lower or equals 50

Send an email notification when the alarm is created

  1. Open the Root rule chain in ThingsBoard.
  2. Add a toEmail rule node after the Device profile node, connected via the Alarm Created relation.
  3. Configure the toEmail node:
    • From template: [email protected]
    • To template: [email protected]
    • Subject template: Abnormal behavior in $\{entityName\}
    • Body template: Maintenance required for heat pump $\{entityName\}. Anomaly score is $\{heatpumpAnomalyScore\}. Please check the heat pump status on the dashboard.
  4. Add a send email rule node after the toEmail node, connected via the Successful relation.
  5. Save the rule chain.

The implementation covers the full lifecycle: train an anomaly detection model on 90 days of historical data, schedule an hourly autodiscovery job, surface results in a Trendz view, write the anomaly score back to ThingsBoard telemetry, and raise an alarm that emails the maintenance team when the score exceeds 50. This proactive approach catches problems such as low coolant levels, blocked filters, or failing compressors early, extending equipment lifespan and avoiding unplanned repairs.