I have an ESPHome device sending power Informationen to HA. When clicking on the sensor entities it used to show the graph for power, energy usage, etc.
For a couple of days (since updating to 2022.12 I believe) it does not a show a graph anymore, but “Statistics not found”. But if I click in show more it jumps to the History panel and shows the graph just fine. If I look at the MariaDB tables the data is there - but for all sensors of one ESPHome device HA does not show them in the pop-up.
It does show them for the Diagnostics sensors and the switch of the device. Also, as the error message points to “No statistics found” and not “No history data” (or something along the lines) there seems to be a connection to the statistics data subset, not the history as such?
No errors in the log, DB working just fine. Deleting and re-adding the device did not do the trick, neither changing entity names or updating using ESPHome. Not quite sure where to keep looking…
As it turns out, only deleting the device and re-adding it, then renaming the relevant entity, solves the problem. I have now found a temperature entity where the pop-up modal wants to show statistics that aren’t there anymore. Anyone have a hint what to look at? Still nothing in the logs and data in the database appears to be fine.
It appears that for some entities no statistics are being recorded. I don’t see anything wrong with the attributes - for example for the Shelly Pro4 where it works for three of the four channels and the settings are exactly the same.
I think I’ve narrowed it down a bit: Even though the database has the statistics for the correct metadata ID, HA claims “no statistics” for this period under Dev Tools → Statistics.
So the recording of the stats doesn’t seem to be a problem, but they seem not to be connected to the entity, even though the metadata entry is there.
I found and fixed the problem: The index of the table was corrupted, for one device it also had duplicate entries. By killing the duplicate entries and optimizing the table the index was rebuild and everything looks good again.
I found a way to make this happen:
Change the unit of a sensor in Esphome after it has been running for a while. Even if you change it back it won’t correct the problem. I have had some luck with changing the unit in the meta entry to the currently used one. This seems to be an undocumented feature that needs some tracking down. But is does look like database change is the only way currently. You could rename the sensor in Esphome entirely to a new one and the new should work.
Yes, it’s a mess.
At some point I’ve renamed “sensor.device_x_wattage” of a power meter to a more sensible “sensor.device_x_power” on the Home Assistant Entity UI and since that, no history of that at all (though the current power is displayed correctly) even after renaming it back.
The only way I was able to have history for this sensor was to remove this device from integrations/ESPHome, and add it again.
I regret trying ESPHome on some of my power meters, never had any issues with Tasmota, mqtt config files was straightforward.
Hi,
I tried to replace the name and the id, but still didn’t work for me.
Before that I’ve checked the DB for duplication and didn’t find any.
Any other suggestion?
thx
Any update here?
I have an ESPHome device where some exposed entities have statistics (temp, humidity) but others don’t (air quality in µg/m³ / device_class: pm25)