Beginner Questions


I’m new here and I don’t have much background in Java. Really good work! I would like to learn more about how does OpenEMS does the allocation of loads. I could see that when the battery is completely full it will automatically send the power to the grid. Where exactly can I see this part of the code? For example, if I want to add more storage sources, for instance, another type of battery, what should I do?

My idea is to create my own system with PV production (maybe also other sources) and different storage systems, that with the EMS the user can decide how to allocate the loads i.e: the user prefers to charge the battery until 80% only and the rest of production goes to the grid.

Hi Carlos,

Thanks for getting in touch. Power is not actually ‘sent to grid’. It rather follows the simple formula that in each point in time Consumption = Grid + Production + Storage (where Grid and Storage may also be negative values, meaning ‘sell-to-grid’ or ‘charge battery’ respectively). I posted some slides of my lecture a while ago here (sorry - German): FH Kiel: Pro 9-12 + OpenEMS Potential.

With this formula in mind we can control:

  • charge/discharge the battery
  • curtail photovoltaics production
  • start additional generators
  • start/stop/reduce consumption

and as a result the grid exchange power will change. And this is what OpenEMS Controllers do.In our Gidpod Live-Demo you can play with this yourself, using OpenEMS as a simulator:

For your use-case you could write a Controller that evaluates with how much power you would want to charge/discharge any of your storage systems (e.g. stop at 80 %). The rest is solved by physicis :wink:


Hello Stefan,

Thanks a lot for the prompt reply. I read the presentation and it helped me to understand much more. Now I have some other questions:

  • So I’m still quite new with Java but I wanted to know exactly where is it stated this simple formula of the consumption is equal to the sum of production, grid, and storage.
  • I can change the values of Grid, Storage, and PV production for fixed values in the simulator, so I can put negative values if I want them to change direction/charge. But of course, all these values including the PV production vary throughout the day. Is it possible to input a series of values? Maybe real-time data?
  • About the Energymonitor feature, I’m not able to make it show trends, do I have to do something specific for it to work?

Thanks again, it is really interesting for me, I’ll keep playing with the simulator and reading the codes so that I can write a controller with the function you suggested.

Best regards,

Hi Carlos,

The calculation for the _sum/ConsumptionActivePower-Channel is here:

Yes of course. The example simulation is just very simplified to not get overwhelmed with everything at once. The simulator uses Datasources to provide the data. In the Gitpod there are three Simulator.Datasource.Single.Direct configured (- by the way: the configuration file for the docker container is here)

You could easily enter multiple values in that configuration (e.g. via Apache Felix or OpenEMS UI) or e.g. use a simulator that takes a CSV-file (see openems/io.openems.edge.simulator/src/io/openems/edge/simulator/datasource at develop · OpenEMS/openems · GitHub).

What do you mean by “show trends” exactly?