Does the state class currently affect anything?

The state class of a sensor (measurement, total, total_increasing) conceptually influences how sensor values are interpreted, but does it actually affect anything in Home Assistant right now?

It doesn’t seem to affect dashboards, they simply show the current value of the sensor. It also doesn’t seem to affect the Statistics integration, where you have to select the correct state_characteristic, for example you would choose sum_differences_nonnegative for a total_increasing sensor while you would choose sum_differences for a total sensor.

It affects whether or not LTS are generated. No state_class, no LTS.

LTS is the data that drives this chart?

image

So if the sensor has no state class at all, then this wouldn’t be there?

But which state class it is has no influence on the stats?

That is history data that is recorded for all sensors based on their update interval. Default retention period for this is 10 days and then it converts to Long Term Storage (LTS). If you click on Show More and then expand to say this month then you will see the mix of data types, assuming there is data.

Here is a sensor that I have specifically blocked LTS. After 10 days there is no more data.

1 Like

Ah, I see. But if the LTS data is there, then it is always the same, no matter which state_class the sensor has?

LTS data is 5 minute max / min / average (or total depending on the state class type). This is then down-sampled to hourly max/min/avg/total after your purge keep days setting.

So no they are not the same. Total type will have a total, measurement type will not.

The state class also determines how the energy dashboard behaves when the value sensor value decreases. It could either mean a negative change (state class total) or it could indicate a meter that always increases until it resets. So when the value is lower you must have just had a meter reset (starting from 0again) and all what is in the total is to be added to what you had before the meter reset (state class total_increasing).