Electric floor heating - consumption calculation

Hi there,

I have Tuya thermostats for electric heating in HA. I would like to calculate energy consumption based on time of heating and known power in W. I am getting state of heating from sensor Big Bathroom consumption. Then converting to kWh by sensor big_bathroom_energy_spend. Finally use utility meter big_bathroom_consumption_daily.

# Power consumption
template:
  - sensor:
      - name: Big Bathroom heating consumption
        unit_of_measurement: W
        state: >
          {% if is_state_attr('climate.big_bathroom_thermostat', 'hvac_action', 'heating') %}
          750
          {% else %}
          0
          {% endif %}
                   
sensor:
  - platform: integration
    source: sensor.big_bathroom_heating_consumption
    name: big_bathroom_energy_spend
    unit_prefix: k
    
utility_meter:
  big_bathroom_consumption_daily:
    source: sensor.big_bathroom_energy_spend
    cycle: daily
  big_bathroom_consumption_weekly:
    source: sensor.big_bathroom_energy_spend
    cycle: weekly
  big_bathroom_consumption_monthly:
    source: sensor.big_bathroom_energy_spend
    cycle: monthly

The problem is that calculated consumption is wrong. You can see on the screen that consumption should be around 1kWh while big_bathroom_energy_spend is saying 8kWh.

Can someone advise how to correct?

Thanks

In template, sensor “Big Bathroom heating consumption” add: “state class: measurement”
Don’t know if this will work but I had a similar issue, and this helped.

Thanks for the idea however it does not help. If I add this line it doesn’t report any consumption.