How to prevent negative values in solar statistics?

Every day at morning I got negative values from my solar panels in the statistics.
image

      - name: solarmax_total_power_today
        unique_id: ef4c1f35-6825-4298-ba55-65589efce315
        slave: 1
        address: 4136
        input_type: holding
        unit_of_measurement: kWh
        data_type: int16
        scale: 0.001
        device_class: energy
        state_class: total
        nan_value: "0" 

I use a Solarmax SMT13 inverter. The inverter is connected via Modbus (Modbus proxy) to HA.

What kind of setting I have to do to prevent this negatives values at the beginning of the day.

Can you post the history graph for sensor.solarmax_total_power_today.

I added the history graph.

Any ideas which I could try to fix the issue?

Nope. None at all. There was a nasty glitch at 11am but nothing at 7am that I can see that would cause this.

That happens every day. It looks like, that statistics is calculating something wrong.
Is there a piece of code, where I can look into?

I found the solution for my issue. I did a wrong configuration for the state_class. The proofed working configuration is:

state_class: total_increasing