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
- Runs every six hours and loads compressor metadata (device ID, location, shift hours, and sizing inputs) from Google Sheets.
- Fetches the last 24 hours of pressure, power, and flow telemetry for each compressor from ThingsBoard and normalizes the readings to consistent fields.
- 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.
- Enriches each compressor’s aggregated data with current ambient conditions from Open-Meteo and the latest industrial electricity price from the EIA API.
- Calculates leak rate, severity, confidence, and cost/savings estimates, then appends a run record to the Leak_History sheet in Google Sheets.
- 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.
- 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.
- 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
- Provide Google Sheets service account credentials and update the spreadsheet ID/sheet names for Compressor_Config (inputs) and Leak_History (logging).
- Add a ThingsBoard API key credential and ensure each compressor row includes the correct ThingsBoard device/entity ID and telemetry keys (pressure, power, flow).
- 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).
- Add Redis credentials and ensure the instance is reachable to cache alert state keys like leak:alert:<compressor_id>.
- Add credentials for Google Gemini (PaLM) plus Slack OAuth and set the target Slack channel.
- Add Gmail OAuth credentials and set the maintenance recipient address, and add a PDFEndpoint bearer token for HTML-to-PDF conversion.