Expert Guide

Advanced configuration for AI optimizers and complex systems.

Peak Shaving Calculator

The Peak Shaving Calculator is a self-learning AI cloud meter that automatically calculates optimal power limits for each hour of the day. It analyzes historical grid consumption, applies configurable tariff rules, and generates peak limits designed to reduce demand charges on your electricity bill.

The module runs as a background job every hour, continuously learning from new consumption data and adjusting limits as the billing month progresses — no manual recalculation needed.

Why peak shaving matters

Grid operators in the Nordics (and many other regions) bill commercial buildings based on their highest power peaks during a billing month. The billing model typically works like this:

Billing modelHow it worksExample
Single peakMonthly charge based on the single highest hourly consumptionHighest hour = 150 kW, rate = 50 SEK/kW -> 7 500 SEK/month
Top-3 averageMonthly charge based on the average of the 3 highest hourly peaksTop 3 = 150, 140, 130 kW -> avg 140 kW -> 7 000 SEK/month
Time-differentiatedDifferent rates for peak/off-peak hoursDaytime peak = 150 kW at 50 SEK, nighttime peak = 80 kW at 25 SEK

The cost of a single spike

A single 15-minute heating boost or chiller startup that pushes consumption from 100 kW to 180 kW can raise your monthly demand charge by 40% — even if the average consumption is well below 100 kW. Peak shaving prevents these costly spikes by setting intelligent hourly limits.

Even modest reductions in peak demand — 5 to 15% — can yield significant annual savings, because demand charges often constitute 30-50% of a commercial building's electricity bill.

How it works

The calculator operates on three core concepts: cost factors, thresholds, and limits.

The algorithm at a glance

Runs every hour

Read grid meterCalculate cost factorRank monthly peaksDerive thresholdGenerate hourly limits

Each hour, the system:

  1. Reads the last completed hour's peak consumption (kW) from the source grid meter
  2. Calculates a cost factor by multiplying the peak by the matching tariff rule's price weight
  3. Ranks all cost factors for the current billing month from highest to lowest
  4. Derives a threshold from the Nth-highest cost factor (where N = peak count)
  5. Generates power limits for each hour in the forecast window, adjusted by tariff weights

Cost factor

The cost factor normalizes peaks across different tariff periods, making them comparable on a single scale.

Cost Factor = Peak kW x Price Weight

For example, if the grid meter recorded 120 kW during a daytime hour with price weight 1.0, the cost factor is 120 x 1.0 = 120. If the same 120 kW occurred during a nighttime hour with price weight 0.5, the cost factor would be 120 x 0.5 = 60 — reflecting the fact that nighttime peaks cost half as much.

The system stores one cost factor per hour in a dedicated output device, building up a complete picture of the month's consumption profile.

Threshold (top-N)

The threshold determines how aggressively the system shaves peaks. It is derived from the Nth-highest cost factor of the current billing month, where N is the configurable peak count.

Threshold = Nth-highest Cost Factor of the current month

Peak countBilling modelThreshold
1Single max peakThe highest cost factor this month
3Average of top 3The 3rd-highest cost factor (since reducing below this has no billing benefit)
5Average of top 5The 5th-highest cost factor

Why top-N matters

If your grid operator bills based on the average of the top 3 peaks, there is no benefit in shaving below the 3rd-highest value — it would not change your bill. Setting peak count to 3 ensures the system targets only peaks that actually affect your demand charges, avoiding unnecessary comfort or process restrictions.

Peak limit per hour

The peak limit for each hour is calculated by dividing the threshold by the hour's tariff price weight:

Limit(h) = Threshold / Price Weight(h)

This means high-tariff hours get stricter (lower) limits and low-tariff hours get more headroom — automatically. The system generates one limit value per hour for the entire forecast window (up to 48 hours ahead).

HourPrice weightThresholdCalculated limit
08:00 (daytime)1.0120120 / 1.0 = 120 kW
22:00 (nighttime)0.5120120 / 0.5 = 240 kW
06:00 (shoulder)0.75120120 / 0.75 = 160 kW
Limits adapt in real time

As each new hour's consumption is recorded, the cost factor ranking updates, which may shift the threshold up or down. The next limit generation cycle automatically reflects this change. Early in the month the limits are based on a baseline; as real data accumulates, the system converges on the optimal threshold.

Self-learning and bootstrap

The system handles three distinct phases:

First run (bootstrap): When no cost factor history exists, the system bootstraps from the source grid meter's last month of hourly data. It computes cost factors for each historical hour using the configured tariff rules, ranks them, takes the Nth-highest, and applies the reduction target to derive a conservative starting threshold. At least one week of historical data is required.

Ongoing learning: Each hour adds a new cost factor to the current month's dataset. The threshold naturally adjusts as more data comes in — if a new peak exceeds the current threshold, the limits tighten; if the month progresses without new peaks, limits remain stable.

Month transitions: When the forecast window crosses into a new billing month (where no cost factors exist yet), the system applies the configured reduction percent to the current month's threshold as a baseline for the new month. For example, with a 10% reduction target and a current threshold of 120, the next month starts with 120 x 0.90 = 108.

Configuring the calculator

Navigate to your property, then open Automation and select AI Cloud Meters. Create a new cloud meter and select type Peak Shaving.

Step 1 — Select source meter

Choose the grid consumption meter that the calculator should monitor. The selector automatically filters to show only consumption meters with grid import flow direction, since peak shaving applies to incoming grid power.

Interval support

The source meter must report at hourly or sub-hourly intervals. Sub-hourly meters (e.g. 15-minute) are supported — the system automatically aggregates sub-hourly samples into hourly totals using SUM. Meters with intervals greater than one hour are not supported.

Step 2 — Set peak count

The number of top peaks used for threshold calculation. Match this to your grid operator's billing model:

Grid operator billing modelRecommended peak count
Charges based on single highest peak1
Charges based on average of top 3 peaks3
Charges based on average of top 5 peaks5

Default: 3 (common Nordic billing model). Range: 1-10.

Step 3 — Set reduction percent

The target reduction from the historical baseline when bootstrapping or transitioning to a new billing month. This is a safety margin — it tells the system to aim for limits that are N% below what historical consumption would suggest.

SettingEffect
0%Limits match historical peaks exactly (no reduction target)
10%Aim for 10% below historical baseline (recommended starting point)
20%Aggressive — may require active load management to stay within limits

Default: 10%. Range: 0-100%.

Conservative start

Start with 10% and monitor the results for a billing cycle. If the building consistently stays well below the limits, increase the reduction target. If comfort or process complaints arise, reduce it.

Step 4 — Set forecast horizon

How many hours ahead the system generates limit values. The limits are written to the output measurement device and can be consumed by building automation systems or dashboards.

Default: 24 hours. Range: 1-48 hours.

Step 5 — Configure tariff rules

Tariff rules define when different pricing applies and how much each period weighs in the cost factor calculation. Each rule specifies:

FieldDescription
Rule nameDescriptive label (e.g. "Daytime", "Night", "Winter peak")
MonthsWhich months this rule applies to (1-12)
HoursWhich hours this rule applies to (00:00-23:00, clock hours)
Weekdays / Weekends / HolidaysDay types this rule covers
Price (cost weight)The relative cost weight for this tariff period

Price weight is relative

The price weight does not need to match actual electricity prices. It represents the relative cost of different periods. If daytime peaks cost twice as much as nighttime peaks, use 1.0 for daytime and 0.5 for nighttime. The absolute values don't matter — only the ratio between them affects limit distribution.

Example configuration — two-period tariff:

RuleHoursMonthsDaysPrice weight
Daytime06:00 - 21:00All (1-12)Weekdays1.0
Off-peak22:00 - 05:00All (1-12)All0.5

With this setup, the system generates limits that are twice as strict during expensive daytime hours compared to cheap off-peak hours.

Example configuration — seasonal tariff:

RuleHoursMonthsDaysPrice weight
Winter peak06:00 - 21:00Nov-Mar (11,12,1,2,3)Weekdays1.5
Winter off-peak22:00 - 05:00Nov-Mar (11,12,1,2,3)All0.5
Summer00:00 - 23:00Apr-Oct (4-10)All0.8
Rule coverage

Make sure your rules cover all hours of the day and all months. Hours without a matching rule produce no limit — the system skips them, meaning no peak constraint is applied for those periods.

Example scenario

Consider a commercial building with the following setup:

  • Source meter: Grid import meter averaging 80-120 kW during business hours, 30-50 kW at night
  • Peak count: 3 (grid operator charges based on average of top 3 peaks)
  • Reduction target: 10%
  • Tariff rules: Daytime (06:00-21:00) weight 1.0, Nighttime (22:00-05:00) weight 0.5

Month progression

Day 1 (bootstrap): The system reads the last month's source data. Historical top-3 cost factors were 145, 138, 132. The 3rd-highest is 132. Applying 10% reduction: 132 x 0.90 = 118.8. This becomes the initial threshold.

  • Daytime limit: 118.8 / 1.0 = 118.8 kW
  • Nighttime limit: 118.8 / 0.5 = 237.6 kW

Day 8: A cold snap pushes consumption to 135 kW during hour 09:00. Cost factor = 135 x 1.0 = 135. This enters the top-3 ranking. The month's cost factors so far might look like: 135, 125, 118, 110, ... The 3rd-highest is now 118. New threshold = 118.

  • Daytime limit tightens to 118 kW
  • Nighttime limit becomes 236 kW

Day 22: The month has stabilized. No new peaks have exceeded the top 3. The threshold remains at 118, and limits stay consistent — the building's automation system has successfully kept consumption below the limits for the remainder of the month.

Visualizing the result

The chart on the cloud meter's detail page shows grid consumption as bars and the calculated peak limit as a stepped line. The limit steps down during expensive daytime hours and up during cheap nighttime hours. Notice how the building's consumption hovers just below the limit during the day — this is peak shaving in action.

In this example:

  • Bars = actual grid consumption (kW). During business hours (06:00-21:00), consumption pushes close to 118 kW — the building's HVAC and processes are running near the calculated limit
  • Line = calculated peak limit. It drops to 118 kW during daytime (price weight 1.0) and rises to 236 kW during nighttime (price weight 0.5), because off-peak peaks cost half as much
  • At hours 09:00, 14:00, 16:00, and 17:00 the building nearly touches the limit — the BMS is curtailing non-essential loads (pre-heating, EV charging, ventilation boost) to stay below it
  • At night the limit is relaxed, giving full headroom for scheduled loads like battery charging or thermal storage

Output devices

When the cloud meter runs for the first time, it automatically creates two output measurement devices:

DeviceTypeDescription
Peak Limitpeak_limitHourly power limit values (kW). Updated each run for the forecast window. These are the values your BMS or automation system should use as setpoints.
Cost Factorcost_factorHourly cost factor values (kW x price weight). Used internally for threshold calculation. Useful for diagnostics and understanding why limits changed.

Both devices appear under the property's measurement devices with collection type Peak Shaving and are linked to the cloud meter that created them.

Formulas reference

FormulaExpressionDescription
Cost FactorCF(h) = P(h) x W(h)Peak kW times the matching tariff rule's price weight
ThresholdT = CF_NThe Nth-highest cost factor of the current billing month
Baseline (bootstrap)T_base = CF_N x (1 - R / 100)Nth-highest cost factor reduced by the target percentage
Month transitionT_next = T_current x (1 - R / 100)Current threshold reduced by target percentage for the new month
Peak LimitL(h) = T / W(h)Threshold divided by the hour's price weight

Where:

  • P(h) = peak power consumption in kW for hour h
  • W(h) = price weight from the matching tariff rule for hour h
  • N = peak count (configurable, typically 1-5)
  • R = reduction percent (configurable, typically 5-15%)
  • CF_N = the Nth-highest cost factor when sorted descending

Holiday awareness

The system automatically detects public holidays based on the property's country code. When a tariff rule has the Holidays checkbox enabled, that rule also matches on public holidays — regardless of whether the holiday falls on a weekday or weekend.

This is important because many grid operators apply off-peak rates on public holidays, and the system should generate correspondingly relaxed limits on those days.

Best practices

  • Match peak count to your billing model — Check your grid operator's tariff contract to determine whether they bill on the single highest peak, top 3, or another model. Setting the wrong peak count means the system optimizes for the wrong target.
  • Start with 10% reduction and adjust — A 10% target is conservative enough to avoid comfort issues while still delivering meaningful savings. Monitor for one billing cycle, then adjust based on results.
  • Cover all hours with tariff rules — Any hour without a matching rule gets no limit, meaning no peak constraint. Review your rules to ensure complete coverage across all months, hours, and day types.
  • Use price weights that reflect actual tariff ratios — If your grid operator charges 3x more for winter daytime peaks than summer off-peak, set weights like 1.5 and 0.5 respectively. The ratios matter, not the absolute numbers.
  • Run the meter before connecting to BMS — Let the cloud meter run for a few days to build up cost factor history and stabilize the threshold before using the limits as BMS setpoints. This prevents overly aggressive limits based on insufficient data.
  • Review limits after tariff changes — If your grid operator changes their tariff structure, update the tariff rules accordingly. The system will automatically recalculate limits based on the new weights.

What's next

The Peak Shaving Calculator generates optimal hourly limits — but limits alone don't reduce consumption. To act on these limits automatically, pair them with the Energy Optimizer AI Schedule, which consumes the calculated peak limits in real time and orchestrates battery dispatch, HVAC load shifting, EV charging, and other flexible loads to keep consumption within the target. The optimizer balances peak shaving against spot prices, comfort constraints, and battery state of charge to find the most cost-effective strategy for each hour.