ConsumptionActiveEnergy reset to 0 upon restart

I’m using OpenEMS Edge and UI in combination with InfluxDB for a few days.
Today I needed to restart the system. After that, the history for the current day wouldn’t load anymore.

Inspecting the edge logs reveals the following:

When I query the data in influx, it seems that the value is set to 0 upon restarting.

How can that be fixed? Is there a way to recover the lost data?

Hi, and welcome to the OpenEMS Community!

The error comes from the assumption, that energy values in OpenEMS are per definition steadily increasing, i.e. Value(t + 1) >= Value(t). This applies e.g. to consumed energy in [Wh_Σ]. To calculate the ‘discrete’ consumed energy in [Wh] for a certain period, the first cumulated value is subtracted from the last cumulated value. If the result is negative - which is not allowed per definition - the warning “Got negative energy value” appears. (see openems/io.openems.common/src/io/openems/common/channel/ at develop · OpenEMS/openems · GitHub)

To make sure that the value is actually steadily increasing is the task of the OpenEMS Component. For some physical devices these values are available via API (e.g. via Modbus), for others OpenEMS is calculating them manually from Power.

So in order to answer the question, I would need to know which actual Components you have configured.

Thanks and regards,

Hi Stefan,

Thanks for your reply and the explanation.

I’m using the following components:

Kind Regards

Ok, those components are examples for implementations where the energy values are calculated from power. Implementation is here: openems/io.openems.edge.kaco.blueplanet.hybrid10/src/io/openems/edge/kaco/blueplanet/hybrid10/ess/ at develop · OpenEMS/openems · GitHub using the CalculateEnergyFromPower class.

The implementation works in such a way, that is uses a local timedata service to store the channel values before restarting. I have not tested this with a local InfluxDB, but only with RRD4j, but in principle this should have worked also.

I suggest you try configuring a local RRD4j timedata service. Start OpenEMS Edge with the parameter, because this is where RRD4j stores its databases:

java -jar openems.jar

After a while stop the system and start it again. The values should not anymore be reset to zero.

Another question out of curiosity: to be able to use these Components, you need an identkey by KACO/Katek. Have you been able to get one from them or how did you get the implementation to connect successfully?
(see discussions here (KACO Wechselrichter verbinden - #7 by stefan.feilmeier) and Pull-Request (Implement KACO Blueplanet Hybrid 10 by sfeilmeier · Pull Request #1966 · OpenEMS/openems · GitHub))


Indeed, with RRD4J the issue does not exist.

What I figured out is that the issues seems to be following measurement in influx:


I have the same issue with ESS charge/discharge energy which is calculated too. I am using an influxdb v2.

I looked at different places in the code but could not find a solution yet.
Maybe someone was successful in the meantime?

@stefan.feilmeier : it works with RRD4J but I don´t think this workaround is very satisfying.


Hi guys,

The fact that after a restart the data from calculated energy values were gone was quite annoying. I have now implemented the getLatestValue method for Influx (InfluxQL and Flux). So far, it can only be found in my fork, but I’ll create a pull request for it in the coming days.



For future readers: this fix has been merged with Influx db/get latest value by DerWahreKlinki · Pull Request #2423 · OpenEMS/openems · GitHub and is included in Release 2023.12.0 (Release 2023.12.0 · OpenEMS/openems · GitHub)

Thanks Klinki for the contribution!