Howto handle average injected kwh to make smart solar pv steering?

I have a digital meter at my home and so i can track the injected kwh in real time.

I would like to start my boiler heater when the injected kwh over the last 15 min is above 3kwh.
In node red i can use event state + 15min, but when a cloud moves for the sun for a small amount of time, and the kwh drops below the treshold, the counter restarts.

All input would be welcome.

Anyone who has a starter?