See llms.txt for all machine-readable content.

Back to Templates

Estimate compressed air leak costs with ThingsBoard, Google Sheets and Gemini

Quick overview

Youtube Video: https://youtu.be/X6l8klc6LGI?si=-UvUFEb0I7su8mOt

This workflow runs every six hours to pull compressor configuration from Google Sheets and pressure/flow/power telemetry from ThingsBoard, enriches it with Open-Meteo weather and EIA electricity tariff data, estimates compressed-air leak costs, and notifies teams via Slack and Gmail with optional PDF escalation reports.

How it works

  1. Runs every six hours and loads compressor metadata (device ID, location, shift hours, and sizing inputs) from Google Sheets.
  2. Fetches the last 24 hours of pressure, power, and flow telemetry for each compressor from ThingsBoard and normalizes the readings to consistent fields.
  3. Filters telemetry to off-shift hours (or treats the site as always-on when shift hours are missing) and keeps only valid readings, then aggregates off-shift statistics per compressor.
  4. Enriches each compressor’s aggregated data with current ambient conditions from Open-Meteo and the latest industrial electricity price from the EIA API.
  5. Calculates leak rate, severity, confidence, and cost/savings estimates, then appends a run record to the Leak_History sheet in Google Sheets.
  6. For non-healthy compressors, compares current severity and annual cost against the last alert stored in Redis and proceeds only for new or significantly worsened leaks.
  7. Uses Google Gemini to generate structured repair recommendations, stores the updated alert state in Redis, and posts a detailed alert with costs and actions to a Slack channel.
  8. For CRITICAL leaks, generates an HTML escalation report, converts it to a PDF via PDFEndpoint, and emails the maintenance team through Gmail with the PDF attached.

Setup

  1. Provide Google Sheets service account credentials and update the spreadsheet ID/sheet names for Compressor_Config (inputs) and Leak_History (logging).
  2. Add a ThingsBoard API key credential and ensure each compressor row includes the correct ThingsBoard device/entity ID and telemetry keys (pressure, power, flow).
  3. Configure compressor configuration columns used by the calculations (timezone, shift start/end hours, rated flow/kW, idle kW, location/state, and any tariff overrides or thresholds).
  4. Add Redis credentials and ensure the instance is reachable to cache alert state keys like leak:alert:<compressor_id>.
  5. Add credentials for Google Gemini (PaLM) plus Slack OAuth and set the target Slack channel.
  6. Add Gmail OAuth credentials and set the maintenance recipient address, and add a PDFEndpoint bearer token for HTML-to-PDF conversion.