Is the "state classes is not correct" repair broken?

I’ve been struggling to get the Energy component up and running to track a few devices around the house. I have almost everything working, but this repair notice keeps showing up when Home Assistant starts and doesn’t go away:

State classes is not correct

State classes total_increasing, total_increasing, total_increasing, total_increasing, total on source entities sensor.total_aquarium_energy_consumption, sensor.espresso_machine_total_consumption, sensor.dishwasher_total_consumption, sensor.total_moss_tank_energy_consumption, sensor.media_server_energy_consumption needs to be same for sensor group sensor.total_power_consumption.

Please correct the state classes on the source entities and reload the group sensor to fix this issue.

It also consistently says the repair is from 3 days ago even though this has been going on for multiple days.

I have used customize.yaml to set the state classes of these entities to total_increasing and restarted Home Assistant, so the only entity with a state class of total in my states page is sensor.total_power_consumption_cost.

I can make the repair go away by removing sensor.media_server_energy_consumption from the sensor.total_power_consumption group, but again, it has the total_increasing state class so the Energy component seems happy to use it.

It appears to me that this repair is incorrect because it claims that one of those sensors has a state class of total when none actually do.

Has anyone else run into this? Am I doing something wrong, or should I open a bug report?

Thanks!

If you navigate to Developer Tools - Statistics, does it show any of those entities as needing to be fixed? Guessing you might have old data that’s giving you problems.

Thank you for the suggestion!

As I’ve been changing energy entity stuff I’ve seen issues appear there, but setting the state_class or unit_of_measurement of my sum sensor groups seems to fix those. Not the “repair”, though.

After changing from one total sensor and individual devices to several meters for different groups and restarting Home Assistant, I now have a similar repair:

State classes total_increasing, total on source entities sensor.pc_total_consumption, sensor.media_server_energy_consumption needs to be same for sensor group sensor.total_computer_energy_consumption.

There are no issues in Developer Tools > Statistics, and in Developer Tools > States, these entities show the following attributes:

sensor.pc_total_consumption

state_class: total_increasing
unit_of_measurement: kWh
device_class: energy
friendly_name: PC Total consumption

sensor.media_server_energy_consumption

state_class: total_increasing
source: sensor.media_server_power
unit_of_measurement: kWh
device_class: energy
friendly_name: Media Server Energy Consumption

sensor.total_computer_energy_consumption

entity_id: sensor.joey_pc_total_consumption, sensor.media_server_energy_consumption
device_class: energy
friendly_name: Total Computer Energy Consumption
state_class: total_increasing
unit_of_measurement: kWh

I should note that sensor.pc_total_consumption is provided by the TP-Link integration, which sets state_class: total_increasing by itself. However, sensor.media_server_energy_consumption is a command line sensor, so I have this in my customize.yaml:

sensor.media_server_energy_consumption:
  state_class: total_increasing

sensor.total_computer_energy_consumption is a sensor group helper with type set to sum, and I have this in my customize.yaml to avoid statistics issues when Home Assistant is starting:

sensor.total_computer_energy_consumption:
  state_class: total_increasing
  unit_of_measurement: kWh

The repair seems to be trying to indicate something is wrong, but the message isn’t accurate.

Possibly related but happening to other sensors as well: each time Home Assistant starts, the current value of the total sensor is dumped as an instantaneous usage, so my Energy dashboard looks like this:

I think there’s a race condition during startup where the sensors are read before their customizations are applied, and then the energy usage jumps once the customizations change the functionality of the sensors.

It’s entirely possible that I’m just using the Energy component incorrectly, and I need to go read/watch some tutorials.