springfall2008 / batpred

Home battery prediction and charging automation for Home Assistant, supporting many inverter types
https://springfall2008.github.io/batpred/
130 stars 44 forks source link

HA error - sensor.predbat_sx4_0_charge_limit no longer has a state class #1638

Open jefft4 opened 1 week ago

jefft4 commented 1 week ago

Describe the bug Since several versions back, HA reports an error "sensor.predbat_sx4_0_charge_limit no longer has a state class". Deleting the history does not resolve the error, as the sensor is in use and creates further history. Sensor entity has no ID, so is not manageable through the HA UI to change it.

Expected behaviour No error, presumably by PB setting the state class attribute of the sensor.

8.6.1 (problem since 8.5.8, possibly earlier)

Environment details

Screenshots image

chris-y commented 6 days ago

I'm getting the same here for a number of entities, and also messages telling me the units have changed from '' to 'W' or back the other way.

These are currently showing as having no state class, although I've seen others for my custom inverter setup: sensor.predbat_mine_0_charge_limit sensor.predbat_mine_0_discharge_rate

cyberkryten commented 3 days ago

Was on a much older version and I'm now also seeing this since I upgraded to 8.7.2 (SolarEdge Inverter and Batteries):

The entity no longer has a state class
We have generated statistics for 'predbat se 0 charge limit' (sensor.predbat_se_0_charge_limit) in the past, but it no longer has a state class, therefore, we cannot track long term statistics for it anymore.

Statistics cannot be generated until this entity has a supported state class.
If the state class was previously provided by an integration, this might be a bug. Please report an issue.
If you previously set the state class yourself, please correct it. [The different state classes and when to use which can be found in the developer documentation.](https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics)
If the state class has permanently been removed, you may want to delete the long term statistics of it from your database.
Do you want to permanently delete the long term statistics of sensor.predbat_se_0_charge_limit from your database?
mask2082 commented 1 day ago

I am getting a similar one for a number of entities.

We have generated statistics for 'predbat sk 0 charge rate' (sensor.predbat_sk_0_charge_rate) in the past, but it no longer has a state class, therefore, we cannot track long term statistics for it anymore.