Delete long term statistics

Is there a way to remove data from long term statistics?

I experience two problems with those:

  1. After updating esphome and reflashing my boards I get this warning:
The unit of sensor.rgb_living_room_wifi_signal (dBm) does not match the unit of already compiled statistics (dB). Generation of long term statistics will be suppressed unless the unit changes back to dB

I tried to remove and add again the integration for this device but the warning is still there. I could probably change the units back to db from esphome but I think it the correct apporach would be to keep it dbm (as esphome thinks is correct) and remove the old long term statistics.

  1. I changed the name of a device on esphome and reflashed. The long term statistics of the device with the previous name are still available and I can select them in a statistics graph card. Is there a way to remove them completely? Are they stored in the database? I could run sqlite on terminal. Is it safe to remove them?

There’s no “easy” way to remove them. Either you delete the whole homeassistant_v2.db file or you manually remove the entries from the database tables with some SQL.

Yes, depends on your recorder database. Look for the entity in table statistics_meta, and replace the dB in row unit_of_measurement with dBm, because only the unit has changed, had the same issue with an ESPHome upgrade. For me it’s easy, because I have recorder write to a mariadb, where I can use a tool with a gui. Think it is a sqlite database otherwise.

1 Like
1 Like