Energy meter glitches

Hi, I think the utility meter sensors need some functionality to avoid glitches when for example z-wave entities go from ‘unavailable’
This glitch will cause some of my entities to have a delta value of for example 8000kWh.
This is a problem, one thing is the graphs are totally messed up, but also automations that are triggered by energy consumption will fire off unnecessarily.
I know I can edit these spikes in the UI, but it also seems like these spikes could easily have been avoided with some added functionality in the utility meters. (ignore ‘unavailable’, max delta value etc)

I have my individual ‘energy’ entities from devices set up in daily, weekly, monthly and yearly energy meters. (dishwasher, washer, boiler, tv, server etc) and I have the “net_consumption: true” set for all of them.
I aggregate these utility meters into template sensors for the same periods based on device “types” (heating, electronics, washers etc) and the issue will of course spread to all of these sensors as well.

Also the my rolling 1h/24h/7d consumption sensors are affected as these are set as statistics sensor with “state_characteristic: change” used to trigger changes in consumption for devices that have a expected consumption (server, hot water etc)

Example: this sensor is based on the sum from all z-wave thermostat energy entities (total) aggregated into a “yearly heating energy” which is then used to create a rolling 24h consumption.

sensor:
  - platform: template
    total_heating_energy:
      device_class: energy
      unit_of_measurement: "kWh"
      value_template: >
        {{ (states('sensor.bathroom_thermostat_energy')|float(default=0)
        + states('sensor.basement_thermostat_energy')|float(default=0)
        + states('sensor.bedroom1_thermostat_energy')|float(default=0)
        + states('sensor.bedroom2_thermostat_energy')|float(default=0)
        + states('sensor.downstairs_thermostat_energy')|float(default=0)) | round(2) }}
utility_meter:
  heating_energy_yearly:
    source: sensor.total_heating_energy
    cycle: yearly
    net_consumption: true
sensor:
  - platform: statistics
    name: "total_heating_energy_24h"
    entity_id: sensor.heating_energy_yearly
    state_characteristic: change
    sampling_size: 10000
    max_age:
      hours: 24
    precision: 4

image