Peaks in calculated template sensor

Hello friends,

I am calculating my direct usage of solar energy.
I refer to the daily measurement from my E3DC inverter.
E3DC resets the values daily.
As the sensor readings and the template calculation interfere, there appears a spike or a peak in my template sensor.

The template sensor is defined withhin the helper ui

{% set netzbezug = states('sensor.s10e_compact_consumption_from_grid_today') | float(0) %}
{% set hausverbrauch = states('sensor.s10e_compact_house_consumption_today') | float(0) %}
{% set batterieverbrauch = states('sensor.s10e_compact_battery_discharge_today') | float(0) %}
{% set batterieverluste = states('sensor.battery_discharge_losses_today') | float(0) %}
{{ (hausverbrauch - netzbezug - (batterieverbrauch - batterieverluste)) | float | round(2) }}

I do the same for the monthly pv self consumption value.
Here I see regular drops:

It seems, the template and the sensor reading are out of sync?

I tried to “overlay” the sensor with a utility meter, that gets reset every day.
But the meter takes over the high readings a makes a skip upwards instead setting back to 0.

Any suggestions, how to get rid of this incosistency.