Overview Block EMS Optimizer



This function block operates a battery storage at a grid connection at the lowest cost. It forecasts consumption and PV generation for the next 24 hours, computes a schedule per quarter hour with a linear program and controls the storage every second so that the energy at the grid connection point matches the schedule exactly at the end of each quarter hour.

It takes into account the energy price (day-ahead spot price with markup and discount), the grid energy charge with a low-price window, levies, a two-tier demand charge on the monthly peak, cycle costs of the storage, the limits of the grid connection and a planned curtailment of the PV, for example at negative prices. The block suits commercial and utility-scale storage as well as smaller systems; all powers are given in kW.

Signs. Grid power and schedule: positive = import, negative = export. Battery power and setpoint: positive = charging, negative = discharging. This is the opposite of the Block Storage optimizer.

Sequence

Energy balance
per quarter hour
Consumption is calculated from grid, battery and PV power: consumption = grid − battery + PV. The available PV is stored, i.e. the measured generation plus the power currently curtailed – so the forecast does not learn from curtailed values. The monthly import peak is tracked as well; it restarts every month.
Weather
four times a day
The irradiance (global horizontal irradiance, W/m²) for the project location is fetched from Open-Meteo in quarter hours – the past and the next 48 hours. Latitude and longitude must be entered in the project settings. If the input Irradiance is connected (for example to a weather station), the measured irradiance is used for learning. Without data the clear-sky irradiance applies.
Forecast
learns four times a day
At 0:30, 6:30, 12:30 and 18:30 two models are learned from the last days (learning window, default 21):
PV = a + b·G + c·G² from the irradiance G,
consumption per hour of the day, separately for working days and weekends or holidays, plus a share of the irradiance.
A short-term correction carries the deviation of the last quarter hour, fading, into the next hours. With less than one day of data there is no forecast yet.
Optimization
every quarter hour
At the start of each quarter hour a schedule for the next 24 hours (97 quarter hours) is computed. The value of the next quarter hour is fixed and not changed by the following run – so it can reliably be reported to a marketer. The import price of each quarter hour is spot price + markup + grid energy charge + levies, the export price is spot price − discount. Where the day-ahead price is not known yet, the price 24 hours earlier applies.
Controller
every second
The controller adjusts the battery power so that the energy at the grid connection point at the end of the quarter hour matches the schedule (PI controller on the remaining energy). The limits of the grid connection minus a margin always take priority. PV is curtailed if the export limit would be exceeded otherwise or if the schedule plans curtailment.

Electricity prices

Where the spot price comes from is set by the parameter Price source of the block. Each source needs a block in the same project and on the same controller:

If the matching block is missing, the EMS optimizer shows a red Preisquelle? in the Studio (if it is on another controller: Steuerung?). In operation the schedule of the operating element states the reason when there are no prices: block missing, no prices, or with Portal the block MQTT EMS platform is missing or inactive, there is no connection to the portal, or the portal has not sent any prices. Without prices no schedule is computed and the controller runs self-consumption.

Set a price block to the plain spot price (VAT and markup 0) – markup, grid tariff and levies are applied by the EMS optimizer itself.

Demand charge. The demand charge is entered per kW and month (annual value ÷ 12), in two tiers below and above a threshold. The program thus sees what raising the monthly peak costs and avoids it where worthwhile.

Low-price window. When enabled, the lower energy charge applies in summer (April to September) from 10:00 to 16:00 and in winter from 23:00 to 5:00.

Load profile in advance

The forecast learns from the block's own recording and needs at least one day for it. So that it can calculate right from the start, the platform sends an existing load profile of the site, e.g. the load curve of the grid operator (see HISTORY under Platform). It fills the learning window as long as the own recording is too short and is replaced by it day by day. The controller keeps it across a restart.

Platform

If the project contains the block MQTT EMS platform, the EMS optimizer exchanges data with the energy platform through it. All messages are JSON {"ts":"<UTC>","value":...}, timestamps in UTC (ISO 8601), power in kW, prices in ct/kWh. Without a platform or without specifications the block keeps optimizing on its own.

The controller stores the platform's specifications (prices, grid limits, setpoints, energy community) at most once an hour. If it restarts and cannot reach the platform, it keeps calculating with the last stored state.

From the controller (below <VPN-ID>/EMS/):

From the platform (below <VPN-ID>/EMS/SET/). Time series are lists of points with the start of the quarter hour; a new message replaces the previous points from its first time on. Every new specification triggers a new optimization immediately. The limits for grid, state of charge, battery and ramp always apply.

State

0StartNo schedule yet, the controller runs self-consumption.
1ScheduleThe controller follows the computed schedule.
2Self-consumptionOperating mode self-consumption: target at the grid connection point is 0.
3ManualBattery power set by hand, the export limit still applies.
4OffSetpoint 0, no curtailment.
5LockedInput Lock set, self-consumption.
6No forecastToo little history, self-consumption.
7No pricesNo price series found, self-consumption.
8Optimization failedThe program found no solution, self-consumption.
9Platform scheduleSchedule source platform: the block controls to the platform's setpoint, without a setpoint to self-consumption.

Inputs

NLGrid power kW Power at the grid connection point, positive = import. Controlled variable, must be connected and should update at least every second.
PVPV power kW Measured generation. Without this input there is no PV forecast.
BLBattery power kW Measured power of the storage, positive = charging. If not connected, the block's own setpoint is used.
SOCState of charge % State of charge of the storage. Must be connected.
GSIrradiance W/m² Optional, global irradiance of a weather station on site. Takes priority over Open-Meteo for learning.
SPLock Optional. Greater than 0: the schedule is not executed, the controller runs self-consumption.

Outputs

ERError1 = no valid schedule.
ZUStateSee table above.
BSBattery setpoint kWSetpoint for the battery inverter, positive = charging.
ARCurtailment kWPower by which the PV is to be reduced.
PGPV limit %The same as a limit in percent of the PV nominal power, 100 = no curtailment.
F0Schedule current kWSchedule value of the current quarter hour at the grid connection point.
F1Schedule next kWFixed value of the next quarter hour.
EVEnergy quarter hour kWhEnergy at the grid connection point since the start of the quarter hour.
PBImport price ct/kWhImport price of the current quarter hour including grid and levies.
PEExport price ct/kWhExport price of the current quarter hour.
SZMonthly peak kWHighest quarter-hour import of the month.
PVForecast consumption kWForecast for the current quarter hour.
PPForecast PV kWForecast of the available PV for the current quarter hour.
KHCost horizon EURValuation of the schedule over 24 hours.
SEState of charge plan end %Planned state of charge at the end of the horizon.

Parameters

Grid import max.Highest import of the grid connection in kW. 0 = no limit.
Export max.Highest export in kW. 0 = no limit.
PV curtailableThe PV inverter can be throttled. Only then the block plans and controls curtailment.
PV nominal powerkWp of the system. Reference for the output PV limit % and for estimating PV of a load profile without PV values.
Price sourceENTSO, aWATTar, eFriends, Portal or Fixed prices, see Electricity prices. Default ENTSO.
DiagnosticsWrites messages about balance, training and optimization to the log and stores the schedule after each run as fb_block_ems_optimizer.csv (controller: /tmp).

These are the commissioning settings. All other settings – operating mode, storage data, markups, grid tariff, optimization weights, forecast and controller – are made in the settings dialog of the operating element Block EMS Optimizer. They are stored in the controller and survive a project transfer. Without an operating element the defaults apply (200 kWh, 100 kW each, grid tariff NE7 Lower Austria).

The block's own recording (up to 60 days) is kept as a file in the boot directory and saved four times a day and on a project transfer.

A right-click on the block leads via Go to linked element directly to the operating element.


See also the general parameters of all function blocks.