Storage optimizer block This function block runs a battery storage according to electricity prices. From the price series, the PV forecast and the state of charge it computes a schedule and derives a power setpoint: negative means charging, positive discharging, 0 standby. The setpoint can be connected directly to the input "Power setpoint" of the Marstek storage block, but in this form it also suits other batteries. For systems that expect the power at the grid connection point instead (for example Victron with ESS) the additional output "Grid setpoint" is available — there negative means feeding in.
The block covers two operating cases with one common method:
How the schedule is built. The block forms pairs of a charging time and a later discharging time and rates each pair with its margin in cent per kilowatt hour. The charging cost already includes the losses of charging and discharging; the margin is therefore the profit that remains after all losses.
What is rated is always a combination of the origin of the energy and its later destination. Both prices of the price source are needed for this:
| Charging from the grid costs | the consumption price of the charging hour, divided by the round-trip efficiency. |
| Charging from generation costs | the feed-in price of the charging hour, divided by the round-trip efficiency. Your own generation is not free: what goes into the battery cannot be fed in — the forgone revenue is the price for it. |
| Own consumption yields | the consumption price of the discharging hour, because exactly that purchase is avoided. |
| Feeding in yields | the feed-in price of the discharging hour. |
Three behaviours follow from this rating on their own, without having to be programmed separately:
All pairs are ordered by their margin and served in that order, as far as charging power, discharging power and the state of charge permit over the whole period.
The schedule only enables, the magnitude comes from the measurement. If the schedule says "charge from generation", the block uses the measured grid power to put exactly the surplus into the battery so that as little as possible flows into the grid. If it says "discharge for own consumption", only as much is taken as the house is currently drawing. This keeps the schedule usable even when the forecast is off.
Without valid prices the battery keeps working on own consumption, only the price optimization is dropped. The setpoint is therefore not simply set to 0. The setting "Behaviour on data loss" allows standby to be selected instead.
The price source does not have to be wired. The blocks eFriends, AWATTAR and Day ahead electricity prices ENTSO provide their price series internally; the selection is made with the setting Price source. An exchange price source knows the consumption price only — for the feed-in the configured feed-in tariff is then used. If no price series is available at all, select the price source "Fixed prices": the block then works with the fixed consumption price and feed-in tariff. With a constant price no charging or discharging plan arises and the battery runs pure own consumption.
For the calculation to be correct, the prices of the source must reflect the cost actually billed. With the exchange price sources their VAT and surcharge parameters have to be set for this (these remain on the respective price block) — the plain exchange price contains neither taxes nor grid fees and would make grid charging look far too cheap.
The schedule is recomputed at the interval set under "Recompute every" — 15 minutes as delivered. Additionally on every interval change, on new prices, after every change in the settings dialog, whenever the PV forecast for today changes noticeably and whenever the measured state of charge deviates noticeably from the plan. The measurement inputs — grid power, state of charge, PV power, consumption and battery power — do not trigger a recomputation; they change continuously and are handled by the real-time control. For the state of charge there is the separate deviation check, which takes effect no earlier than one minute after the last computation.
Recording. Every hour the block
stores grid consumption, feed-in, generation, consumption, charged and
discharged energy, the state of charge as well as cost and revenue in euros;
the data is kept for two years. It is shown in the charts of the Block
storage optimizer control element. The amounts in euros are built
continuously with the price valid at that moment — they cannot be derived
from kilowatt hours times a fixed price once the tariff changes every
hour.
Only what is measured gets recorded.
If the input Grid power is unused
there is no consumption, feed-in or monetary channel; without PV
power no generation, without Battery
power no charging and discharging, without State
of charge no charge curve. Used means: an address or
a connection to a neighbouring block. Consumption is recorded even when only
the PV power is connected — the block then computes it itself.
Every computation starts at now. The first interval of the schedule is therefore shorter than the others and only holds the energy that still fits into the time remaining. In the schedule dialog the bar of the current hour is thus the power for the rest of that hour, not its average — after an interval change it grows back to full height.
Recording consumption and PV yield. The consumption of a house depends on the hour and the day of the week — a single fixed value is too rigid for that. The block therefore measures along every second and builds two profiles from it: consumption for every hour of every weekday (168 values) and the PV yield as a daily curve over 24 hours. The setting "Base load" only applies to hours for which there is no measurement yet.
Measurement runs through the input "Consumption". If it is not connected, the block computes the consumption from PV power, grid power and battery power — the same method as the Energy monitor block. If neither consumption nor PV power is connected, no recording takes place: without the generation the midday value would be systematically too low, and a wrongly learned profile would be worse than the fixed value.
At the end of each hour the hourly average enters the profile — not as a replacement of the old value but as a moving average with the configured learning rate. Outliers are limited beforehand to four times or a quarter of the previous value. A single unusual day — party, holiday, thunderstorm — therefore shifts the profile only slightly and fades out over the following days. The very first measurement of an hour is taken over directly so that an empty cell does not creep towards the correct value for weeks.
A cell is only filled once that hour has passed on that weekday — a complete profile therefore takes a week. As long as the cell itself is still empty, the average of the same hour across the weekdays already learned applies. The time of day shapes consumption far more than the weekday, so the profile takes effect after the first full day instead of only after a week. Only when nothing at all has been learned for an hour does the configured base load apply. The diagnostic CSV file records the origin per interval: "Profil", "Profil (Stundenmittel)" or "Parameter".
The PV profile additionally replaces the fixed bell between 6:00 and 20:00: the daily total from the forecast is distributed over the curve actually observed, which thus follows the season by itself. If no PV forecast is connected at all, the profile serves directly as the generation value.
Both profiles are stored and are available again immediately after a restart or after transferring a project. With diagnostics switched on the block outputs them as a message on every full hour; they get no addresses of their own.
The schedule has no addresses. Setpoint, consumption price and planned state of charge per hour are stored as runtime data in the controller and shown in the control element Block storage optimizer as vertical bars — one column per hour, up to 48 hours ahead. Several hundred values per block would be unwieldy as an address range.
What the recording does not do: public holidays look like a normal working day and pull its profile down. A longer absence lowers the values over several weeks, and the recovery takes just as long. After one week every one of the 168 cells has a value; the profile has settled after about four to six weeks.
Inputs |
||
| NL |
Grid power W |
Measured power at the grid connection point. Positive means import, negative means delivery to the grid. This input is the controlled variable and must be connected. |
| PV |
PV power W |
Current generation, always positive. Optional. Needed for the recording and for the display in the control element. |
| VB |
Consumption W |
Measured house consumption. Optional — if the input is not connected, the block computes the consumption from PV power, grid power and battery power. |
| BL |
Battery power W |
Measured power of the battery. Negative
means discharging, positive means charging — the opposite of
the output "Power setpoint". The signs match the Energy
monitor block. On a system with a setpoint at the grid connection point this input should be connected. It lets the block separate the house load from the battery power and build the output "Grid setpoint" correctly. Without this measurement it assumes the storage follows the output "Power setpoint" — which is not the case with a setpoint at the connection point. |
| SOC |
State of charge % |
Measured state of charge of the battery. Without this value no schedule can be computed, so the input must be connected. |
| P0 |
PV forecast today Wh |
Expected generation of the current day, for example from the block Solar forecast. Optional — without a forecast the learned PV profile is used. |
| P1 |
PV forecast tomorrow Wh |
Expected generation of the following day. Optional. |
Operating mode, the locks and the manual setpoint are not inputs. They are operated together with all other settings in the control element Storage optimizer block.
Outputs |
||
| ER |
Error |
1 if no valid price series is available or the battery capacity is 0. The block then falls back to the configured behaviour on data loss. |
| LS |
Power setpoint W |
Setpoint for the battery: negative = charge, positive = discharge, 0 = standby. |
| NW |
Grid setpoint W |
Setpoint at the grid connection point for systems that
expect this quantity instead of the battery power (for example Victron
with ESS). Positive means import, negative means feed-in. The value is
limited to the grid connection limit. A value is only given where the block wants a particular flow at the connection point: charging from grid, discharging to grid, charging at the feed-in limit and manual. In all other states — self-consumption, charging from generation, standby and off — this reads 0, which means "hold the connection point at zero". The system then regulates itself, at its own speed; the ramp and the control gain do not act on this output. They act on "Power setpoint" — use that output to command the storage directly. |
| ZU |
State |
0 = standby, 1 = charge from PV, 2 = charge from grid, 3 = discharge for own consumption, 4 = discharge to grid, 5 = manual, 6 = emergency operation, 7 = off, 8 = charge at the feed-in limit (the generation alone exceeds the limit, the surplus is charged instead of being curtailed). |
| LA |
Charging active |
1 while the battery is being charged. |
| EN |
Discharging active |
1 while the battery is being discharged. |
| NA |
Grid charging active |
1 if the charging energy comes from the grid. |
| EA |
Feed-in active |
1 if energy is delivered from the battery to the grid. |
| NG |
Grid charging blocked |
1 if grid charging would be profitable but is prevented by the lock or by the minimum profit. Always 0 in the manual and off modes, because the storage does not follow the schedule there. For diagnostics only. |
| PG |
Schedule valid |
1 while a computed schedule is available. |
| ST |
State of charge target % |
Planned state of charge at the end of the current interval. |
| EL |
Planned charging Wh |
Total planned charging energy over the next 24 hours. |
| EE |
Planned discharging Wh |
Total planned discharging energy over the next 24 hours. |
| GE |
Expected yield [EUR] |
Expected profit of the schedule over the next 24 hours in euros, after deducting all losses. |
| NL |
Next charging in min |
Minutes until the next planned charging window, -1 if none is scheduled. |
| NE |
Next discharging in min |
Minutes until the next planned discharging window, -1 if none is scheduled. |
| PB |
Consumption price current [Ct] |
Consumption price of the current interval in cents per kilowatt hour. |
| PS |
Feed-in price current [Ct] |
Feed-in price of the current interval. If the price source does not know a feed-in price, the configured fixed feed-in tariff is shown here. |
| VI |
Consumption measured W |
The consumption currently in use — either from the input "Consumption" or computed. |
| VP |
Consumption learned W |
The value learned for the current hour. 0 as long as there is no measurement for this hour yet and the base load applies. |
| VA |
Recording coverage % |
Share of the already filled cells of the consumption profile. After one week this reads 100 %. |
Parameters |
||
| Grid connection limit W | Highest power the grid connection may carry in one
direction. The limit applies in both
directions — to the feed-in as well as to charging from the
grid. 0 means unlimited. For the feed-in the generation is counted first: if it alone already exceeds the limit, the block charges the surplus into the battery instead of curtailing it (state 8). For the import the house load is counted, and the battery may only draw the remainder. |
|
This is the only parameter of the block. All other settings — operating mode, locks, battery data, state of charge limits, price source, economics, recording and control — are made in the settings dialog of the control element Block storage optimizer. They are stored in the controller and survive the transfer of a project.
Without a linked control element the block works with its default values: automatic mode, automatic price source, 10 kWh capacity (the dialog expects the value in Wh, so 10000), 2500 W charging and discharging power each, state of charge 10 to 100 %. It runs with those, but it is not matched to the installation.
A right click on the block leads straight to the control element via Go to linked element. If several are linked, all of them are offered.