Is there any way to edit a sensor's history?

One of my sensors returned some bad data, and those values are throwing off the vertical scale on the history graph, to the extent that the variations I’m interested in can’t be seen at all. The graph is of temperatures, and the bad data is -575F. So the difference between 68 and 72 is invisible.

Is there a way to remove those erroneous data points? The points are from a climate current_temperature attribute.

You can with sql quite easily.

I’ve read through the linked thread, and I see that you must be talking about the icon with the little ramp with an arrow on it. My statistics page only shows that icon for the energy summation lines.

Any other ideas? I might be willing to try doing it with sql, but would need to be pointed at a tutorial.

Here’s an example of how you can delete a bad reading with sql - in my case, it was an impossible value (65536) for the fan speed of my heat pump.

The sensor (sensor.heatpump_fan_cfm) doesn’t appear in the Statistics tab, so I had to go to the database itself. Here’s what I did (I’m running inside a Docker container, but I did the work outside the container).

> cd config/homeassistant # Go to the directory with my HA configuration, database, and logs.
> sudo sqlite3 home-assistant_v2.db # Open the database; it’s owned by root, hence the sudo
select * from states where state = 65535 and metadata_id = (select metadata_id from states_meta where entity_id = 'sensor.heatpump_fan_cfm'); # Make sure I’m getting the right entry to delete.
delete from states where state = 65535 and metadata_id = (select metadata_id from states_meta where entity_id = 'sensor.heatpump_fan_cfm'); # Do the deed
.quit # all done

The erroneous value was gone, and my history graphs were useful again.

2 Likes

Thank you! I’ve been away from the forum for a while, so I only just saw this.

anyone know why only some entities have the editing possibility in gui?

Neo, I’m in!
Use saba share and add your IP address as a client