Statistics sensor and total_increasing sensor - weird behaviour

Hi!

I’m trying to build sensors so that I can see the total amount of energy for heating and hot-water in relation to total energy for the whole house.

For this I thought I’d use the statistics integration. It mostly works, but I see odd behaviour for some of the statistics sensors.

I have two that look at a meter from within HA that gathers heat and hot-water energy use, they have state class “total” and seems to look back in time to create the statistics.

And then I have another that looks at a sensor from the energy meter, with state_class “total_increasing”, and that one doesn’t look back in time to create the statistic.

Does anybody know is it’s supposed to work this way or if it’s a bug?

Not working:

  - platform: statistics
    unique_id: kWh_last_24h
    name: "Totalt kWh last 24 hours"
    entity_id: sensor.energy_consumed
    state_characteristic: change
    sampling_size: 10000
    max_age:
      hours: 24

Working:

  - platform: statistics
    unique_id: kWh_heat_last_24h
    name: "Heat kWh last 24 hours"
    entity_id: sensor.ctc_energy_meter_heat
    state_characteristic: change
    sampling_size: 10000
    max_age:
      hours: 24