Allow Sample time for integration sensor

I’ve been having a lot of success using the internal integration sensor to totalise several ‘W’ readings into ‘kWh’ readings and creating virtual sensors (updated via appdeamon) to keep track of daily/ weekly usages per bit of equipment in my house.

This is all working relatively as intended other than my hot water heater which has sporadic usage and AFAIK the integration sensor is not able to handle this in its current form.HW_Energy HW_Power

From above the hot water heater was drawing ~3500W for around an hour so the energy should have totalised to be around 3.5kWh but instead it totalised an extra 100kWh immediately on usage (10:57) then went up steadily from there. Its like the integration sensor assumed there was the 3500W consistently from the last time the sensor was updated?

From my knowledge (which is probably wrong) we have the choice of Left, Right or Trapezoidal methods to totalise the value over the sample period, but no way to increase the sample period for ‘Spikey loads’. My integration sensor below with the sensor.6c_ct5_watts_2 reading in Watts

#Hot Water Heater
- platform: integration
  source: sensor.6c_ct5_watts_2
  name: hotwater_energy
  method: left
  unit_prefix: k
  unit_time: h
  round: 2

Thinking about it more, the correct result could also be achieved by implementing a threshold variable, where the integral only takes effect when the sensor is above a certain value. This would reduce the overhead of constantly having to poll a sensor that isn’t changing value.