Skip to content
Stand with Ukraine flag

Pump Status from Relay, Flow and Pressure

  • Calculated Field
  • 169 installs
  • v1.0.0
  • Jun 15, 2026
  • MIT license
  • v4.2+

Derive a single equipment state (idle, running, dry-run-fault, idle-pressurized) from relay, flow, and pressure signals — for pumps, compressors, HVAC, generators, and conveyors.

Type
  • Script
Category
  • Custom Formula
Use Cases
  • Industrial Automation
  • Predictive Maintenance

Who it’s for

Plant operators, maintenance engineers, and SCADA dashboard authors asking “is the pump actually running?”, “is the motor on but the flow is dead?”, “is the compressor pressurised but idle?” — when “is it on?” depends on three signals working together rather than one.

What it does

Reads the latest relay, flowRate, and pressure telemetry from the device and emits one human-readable state string — “running”, “dry-run-fault”, “idle-pressurized”, or “idle” — based on which combination of inputs is matched. The output recomputes on every update.

Pump Status diagram

How to customize

  • To use this on different device keys — change the Time series key on each argument (e.g. relaymotorRunning, flowRateflowLpm, pressureoutletPressure).
  • To rename the output — open the script and replace state in the return object with the key your downstream dashboards and alarms expect (e.g. pumpState, compressorStatus).
  • To change what counts as running, idle, or fault — open the script and adjust the branch thresholds or polarity. Add new branches if your equipment has additional states.
  • To timestamp the state change with the latest input reading instead of server time — the script currently returns the output key at the top level, so the record uses server time. Wrap the return in a values envelope keyed by ctx.latestTs (resolves to the max across all non-default arguments) to use the most recent input timestamp instead.
  • To use a different fallback when no data has arrived — change Default value on each argument (relay defaults to false, numeric inputs to 0).

Share Your Calculated Field with the Community

Built a useful data transformation? Export it as a JSON from ThingsBoard and publish it to the IoT Hub. Share it with thousands of ThingsBoard developers worldwide.