Active and Reactive Power Calculation
Calculate active power (W), reactive power (VAR), and apparent power (VA) from voltage, current, and power factor (cos φ) — for industrial motors, three-phase loads, inverters, and energy-management dashboards.
Who it’s for
Energy managers, plant electrical engineers, and renewable-installation operators asking “how much real power are we drawing?”, “what’s our reactive load?”, “are we close to the kVA capacity limit?” — when “power” as one number isn’t enough and you need the three components separately.
What it does
Reads the latest voltage, current, and cosPhi (power factor)
telemetry on every update, and returns three related power metrics
atomically:
All three come from the same input snapshot in a single calculation, so downstream consumers always see consistent values across the three outputs.
How to customize
- To use this on different meter keys — change the Time series
key on each argument (e.g.
voltage→phaseVoltage,current→lineCurrent,cosPhi→pf). - To use a different fallback when no data has arrived — change
Default value on each argument (
voltageandcurrentdefault to0, andpowerFactordefaults to1, i.e. resistive load). - To handle a phase angle instead of cosine — if your meter
reports the phase angle in degrees rather than
cosPhi, open the script and computecos(angleDeg × π / 180)before using the value. - To rescale the outputs — open the script and divide each return
value by
1000to emit kW / kVAR / kVA instead of W / VAR / VA. Or rename the keys (activePower,reactivePower,apparentPower) to match your domain. - To change the output precision — adjust Decimals by default on the output to whatever precision your dashboards and alarms need.
- To timestamp the result with the latest input reading instead of
server time — the script currently returns the output keys 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.
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.