Inputs
- Prices: the Polish TSO publishes day-ahead prices (RCE) in 15-minute periods; tomorrow's prices arrive around 14:00.
- Consumer price = (energy + distribution + levies) × VAT. VAT also widens the differences between hours.
- PV: irradiance forecast (Open-Meteo) × a factor calibrated on the last days' production.
- Consumption: the average of the same hour over 14 days, separately for weekdays and weekends.
The model
The state is the battery's state of charge, split into 40–200 levels. In each slot we pick a transition to another level within the power and efficiency limits. Slot cost = import × buy price − export × sell price + battery wear. Dynamic programming from the end of the horizon backwards yields the optimal plan. For two days in 15-minute slots that takes a fraction of a second.
for t in reversed(slots):
for soc in levels:
best[t][soc] = min(
slot_cost(t, soc, nxt) + best[t + 1][nxt]
for nxt in reachable(soc) # power limit, efficiency, min/max SOC
)
Details that make the difference
- Battery wear as a cost: battery price / (2 × capacity × cycle count). Example: PLN 20,000, 9 kWh, 6,000 cycles ≈ PLN 0.19 per kWh in each direction. Without it, the optimiser churns the battery for pennies.
- Value of energy at the end of the horizon. Without it, the plan empties the battery right before the forecast ends. We value it at average buy price × efficiency × 0.9.
- Loads before the battery: the water heater, EV charger and washing machine get the cheapest window or the PV surplus.
- Comparison with no strategy (battery charged from PV surplus only). Savings must be a number, not a promise.
- A forecast is only as good as its data. An EV charger left on for a whole day can inflate the consumption profile several times over. That's why the power of loads with their own meter is subtracted from the base consumption.
From plan to control
The plan is more than a chart. The gateway receives the schedule and runs it on its own, even when the internet is down. A manual switch lasts one hour, then the gateway returns the device to its previous state – nobody leaves the charger on "forever".
The energy strategy runs in Polbyte IoT. Building your own EMS or need optimisation for a specific tariff? Let's talk.
Facing a similar problem?
Describe it in two sentences. We'll tell you whether and how we can help.
Get in touch →