Skip to content
Stand with Ukraine flag

Active and Reactive Power Calculation

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

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.

Type
  • Script
Category
  • Custom Formula
  • Energy
Use Cases
  • Smart Energy
  • Smart Metering
  • Industrial Automation

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:

Power triangle diagram

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. voltagephaseVoltage, currentlineCurrent, cosPhipf).
  • To use a different fallback when no data has arrived — change Default value on each argument (voltage and current default to 0, and powerFactor defaults to 1, 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 compute cos(angleDeg × π / 180) before using the value.
  • To rescale the outputs — open the script and divide each return value by 1000 to 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 values envelope keyed by ctx.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.