Power Integration Bug or Configuration error

How should I configure the Integration sensor to calculate the power consumption of the floor heating.

I have the template sensor defined which is providing the power of the floor heating.

- sensor:
      - name: "kh_therm_power"
        unit_of_measurement: "W"
        device_class: "power"
        state: >-
          {%- set power=0.0 %}
          {%- if state_attr('climate.kh_therm', 'hvac_action') == 'heating' -%}
          {%- set power=747.2 %}
          {%- endif -%}
          {{ power }}

And the integration sensor as follows:

  - platform: integration
    source: sensor.kh_therm_power
    name: kh_therm_energy_spent
    method: left
    unit_prefix: k
    round: 3

The intgration sensor works but the calculation is way off…

November 10th night the 747W power was on for 4 hours result should have been 2,988 kWh. But incorrectly it was 3,77 kWh.

For the November 9th the trapezoidal method was used, but results were even more weird and after 6pm the kWh reading jumps up when the heating is turned on. Note: after 9pm the energy value was reset to zero manually and method changed to the ‘left’

Is there bug in the Integration code or is here some sort of wierd configuration error?

Did you ever find a solution for this? I’m experiencing the same issue:

The integration sensor configuration is exactly as described in the documentation:

- platform: integration
  source: sensor.pool_filter_pump_power
  name: Pool Filter Pump Energy
  unit_prefix: k
  round: 2

I’ve got the same issues Simon. Values from calculations using this integration are way higher than the value coming from the same device that actually reports kWh too. Did you find a fix?

You must set the method to left if your power consumption does not always continuously climb.

  - platform: integration
    source: sensor.pool_pump_power
    name: pool_pump_kwh_calculator
    unit_prefix: k
    round: 2
    method: left

As discussed in the github issue: The Power Integration (Riemann sum) calculates incorrectly. · Issue #81958 · home-assistant/core · GitHub
It seems that cast to float needs to be added to the template values used in the intgration.

For me the intgration has worked correctly after adding casts to floats to the used templates.