Feature Request: TimeOfUse controller: Discharge to grid

Hi all

User in Belgium here. I understand German rules are perhaps a bit different.

I have a 50kWh battery pack and have a dynamic energy contract.
Over the last few weeks, I see quite often some negative prices, which means I end up paying for injecting to the grid.
I have implemented a “disable feed” so I do not inject to the grid when the prices are negative.

Currently, I wake up with a battery pack at 80% capacity. It quickly fills up and by noon, the battery is full. As of then, I limit the injection to the grid and thus significantly impact my PV yield, as it only covers my consumption.

I have implemented a very basic: If SPOT price is high between midnight and noon, use the crtlFixActivePower to discharge to grid. However, I would like to be able to use the prediction values to actively discharge my battery pack when the prices are high.

Could the TimeOfUse controller handle this too? My java skills are not great - hence this feature request.


that’s a very interesting use-case. I was not aware that this is already possible in Belgium. Could you share some more documentation to read up on the details of this? Is your feed-in-tariff directly coupled to day-ahead/spot prices?

I am still heavily working on restructuring the Time-of-Use Tariff Controller to make the features available for different multi-use applications, so I might not yet be ready to accept PRs here. But first step to start your “SELL_TO_GRID”-mode would be to add a new mode here → openems/io.openems.edge.controller.ess.timeofusetariff/src/io/openems/edge/controller/ess/timeofusetariff/StateMachine.java at develop · OpenEMS/openems · GitHub

And then check your Eclipse warnings and see where this change requires you to make adaptions. E.g. you will have to adjust the internal cost-function to handle SELL_TO_GRID “costs”. → openems/io.openems.edge.energy/src/io/openems/edge/energy/optimizer/Simulator.java at develop · OpenEMS/openems · GitHub


Hey Stefan,

Thank you for your reply.

In terms of details; there aren’t any restrictions in Belgium (at least for residential or SME customers).

For residential customers, the only limitation is that your inverter can only output 10kWp. If you want to exceed this, you can ask for a (free) grid study so you can go up to 25kWp (which I did). If you want more, more restrictions apply. Unfortunately all documentation is very regionalised, so it’s only available in Dutch (my area). If you need more, I can translate it for you.

My dynamic tariff used to have a 1 on 1 mapping with the spot prices. Now, my energy provider has introduced a margin for injection: -0,9050 + 0,1000 x ESPOT, which basically means they are taking 0.01 euro per kWh. It means that if I inject when the SPOT price is less than 10 euro per MWh, I end up paying. I guess this has to do with the increased unbalance costs. There are also no grid costs when injecting.

When importing, there are a lot of taxes in BE added (grid costs), and the base formula is 1,1000 + 0,1000 x ESPOT.

I’ll have a look at the places to include this function.

Thanks again