Pump Status from Relay, Flow and Pressure
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.
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.
How to customize
- To use this on different device keys — change the Time series
key on each argument (e.g.
relay→motorRunning,flowRate→flowLpm,pressure→outletPressure). - To rename the output — open the script and replace
statein the return object with the key your downstream dashboards and alarms expect (e.g.pumpState,compressorStatus). - To change what counts as
running,idle, orfault— 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
valuesenvelope keyed byctx.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 to0).
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.