Integration - Riemann sum integral, Stop Counting

Hi HA community,
I will need your support on the issues what I straggle last days.
I’m using a Riemann sum to calculate kWh used in my house, i have a solar panel, and during the day consumption are 0, when its 0 longer, sum are not calculated.
i have to reset a HA to calculate it again.

  • platform: integration
    source: sensor.grid_power_in
    name: energy_spent
    unit_prefix: k
    unit_time: h
    method: left
    round: 2

Do you have any tips what can i do?
i tried use all Riemann sum method

Mateusz Sobalski

That is working as expected. Integrating 0 with respect to time will not produce any change. The area under the line along 0 is 0.

Sorry m8,
I explain it wrong.
When is 0 for a long time and then when power appear don’t count it any longer.