DEV Community

Cover image for Energy Consumption in Python: Nameplate Watts x Clock Hours Overstates Your Bill by 2x
Evgenii Konkin
Evgenii Konkin

Posted on

Energy Consumption in Python: Nameplate Watts x Clock Hours Overstates Your Bill by 2x

Every "how much does this cost to run" estimate starts with the same line:

kWh = watts / 1000 * hours
Enter fullscreen mode Exit fullscreen mode

It's correct. The problem is which hours you plug in. A 1,500 W space heater set to run from 10 pm to 6 am is on for 8 hours, but its thermostat switches the element off whenever the room is warm enough. If the element is actually heating half of that time, the real number is 4 hours, not 8.

Nameplate watts times clock hours gives you the worst case. For anything with a thermostat, a humidistat or a compressor, the worst case can be about twice the real use. Here's a small script that keeps the two apart.

The model: power x time x duty cycle

Duty cycle is the fraction of the "on" time that the load actually draws its rated power. A resistive heater with a thermostat is a good fit for this model: it's either full power or off.

kWh/day   = P_kW * hours_on * duty
kWh/month = kWh/day * 30.4368      # 365.25 / 12, an average month
Enter fullscreen mode Exit fullscreen mode

Using an average month of 30.4368 days instead of 30 keeps the monthly and yearly numbers consistent (×12 gives exactly 365.25 days).

The script

DAYS_PER_MONTH = 30.4368   # 365.25 / 12
RATE = 0.18                # $/kWh, roughly the U.S. residential average (EIA, Aug 2026)

def monthly_kwh(watts, hours_on, duty=1.0):
    """Energy per month for a load that is ON for hours_on per day
    but actually draws power only `duty` of that time."""
    return watts / 1000 * hours_on * duty * DAYS_PER_MONTH

def duty_from_meter(kwh_measured, days, watts, hours_on):
    """Back out the duty cycle from a plug-in meter reading."""
    effective_hours = kwh_measured / days / (watts / 1000)
    return effective_hours / hours_on

loads = [
    # name,                 watts, hours on/day, duty cycle
    ("Space heater (bedroom)", 1500,  8, 0.50),
    ("Electric blanket",        100,  8, 0.40),
    ("Heat tape on pipes",      150, 24, 0.30),
    ("Block heater (car)",      400,  4, 1.00),
    ("Dehumidifier",            300, 12, 0.60),
]

real_total = naive_total = 0.0
print(f"{'load':24} {'naive kWh':>10} {'real kWh':>9} {'real $':>8}")
for name, w, h, d in loads:
    naive = monthly_kwh(w, h)
    real = monthly_kwh(w, h, d)
    naive_total += naive
    real_total += real
    print(f"{name:24} {naive:10.1f} {real:9.1f} {real * RATE:8.2f}")
print(f"{'TOTAL':24} {naive_total:10.1f} {real_total:9.1f} {real_total * RATE:8.2f}")
print(f"nameplate x clock hours overstates by {naive_total / real_total:.2f}x")

# a week on a plug-in meter: 42 kWh, heater set for 8 h a night
d = duty_from_meter(42.0, 7, 1500, 8)
print(f"measured duty cycle: {d:.0%}")
Enter fullscreen mode Exit fullscreen mode

Output:

load                      naive kWh  real kWh   real $
Space heater (bedroom)        365.2     182.6    32.87
Electric blanket               24.3       9.7     1.75
Heat tape on pipes            109.6      32.9     5.92
Block heater (car)             48.7      48.7     8.77
Dehumidifier                  109.6      65.7    11.83
TOTAL                         657.4     339.7    61.14
nameplate x clock hours overstates by 1.94x
measured duty cycle: 50%
Enter fullscreen mode Exit fullscreen mode

The duty cycles in the list are illustrative, not measured values for any product. The point is the shape of the result: a winter list that looks like 657 kWh a month on paper is about 340 kWh with realistic duty cycles. At 18 cents per kWh that's about $118 versus $61.

Where the duty cycle comes from

Guessing a duty cycle is fine for a first pass. Measuring it is better, and it's cheap.

  1. Put the load on a plug-in energy meter for a few typical days. Note the kWh and the number of days.
  2. Divide by days to get kWh per day.
  3. Divide by the rated kW to get effective hours per day.
  4. Divide by the scheduled hours to get the duty cycle.

For the heater: 42 kWh over 7 nights is 6 kWh a night. 6 ÷ 1.5 kW = 4 effective hours. 4 ÷ 8 scheduled hours = 50%. That's what duty_from_meter() does.

Once you have the measured kWh per day, you don't even need the duty cycle for the bill. You can scale the meter reading directly. The duty cycle is useful when you want to change something: a lower thermostat setting, a shorter schedule or a smaller room all show up as a lower duty cycle.

Where the simple model breaks

  • Compressor loads are not on/off at rated power. A dehumidifier or a refrigerator draws a startup surge and then a running power that changes with conditions. For those, measure average watts or kWh rather than trusting the nameplate.
  • Inverter equipment modulates. Variable-speed heat pumps and mini-splits run at partial power for long periods. "Duty cycle" stops being a meaningful number; use measured kWh.
  • Duty cycle depends on the weather. A heater that runs 50% of the time on a 40 °F night might run 80% on a 10 °F night. One week of metering in mild weather will underestimate January.
  • Some loads have no thermostat at all. The block heater in the list runs at 100% whenever it's plugged in. Those are the ones where a timer saves the most.
  • The bill isn't just kWh x rate. Tiered pricing, time-of-use rates and fixed monthly charges change the cost. The kWh estimate is still the right first step.

Quick rule

For thermostat-controlled resistive loads, energy = rated kW x hours on x duty cycle. Nameplate watts times clock hours is an upper bound. In this example, a 1,500 W heater on an 8-hour schedule is 365 kWh a month on paper and about 183 kWh in practice, around $66 versus $33 at 18 cents.

Your turn: have you ever put a plug-in meter on a space heater or a dehumidifier? Post the watts, the schedule and the kWh you measured in the comments and I'll run the duty cycle through the script.

Top comments (0)