Hey folks, this isn’t strictly a development question although I could script this or possibly add it to a future integration.
I’ve been attempting to clear the past history data for a utility meter that was set up using Settings → Devices and Services → Helpers. To be specific, it’s one of the three “tarrifs” Utility Meters that was created for me.
I’ve got influxdb integration, so I manually ran two commands that I thought would clear the data – one for the sqlite3 db, and one for influxdb:
sqlite3 home-assistant_v2.db "DELETE FROM states WHERE metadata_id IN (SELECT metadata_id FROM states_meta WHERE entity_id='sensor.pg_e_off_peak');"
sqlite3 home-assistant_v2.db "VACUUM;"
influx delete --org redacted --bucket homeassistant --start '1970-01-01T00:00:00Z' --stop '2100-01-01T00:00:00Z' --predicate '_measurement="Wh" AND _field="value" AND entity_id="pg_e_off_peak"'
After running both commands, I ran select queries to verify that the tables returned no data:
sqlite3 home-assistant_v2.db "SELECT m.entity_id, s.state, s.last_changed FROM states s JOIN states_meta m ON s.metadata_id = m.metadata_id WHERE m.entity_id='sensor.pg_e_off_peak' ORDER BY s.last_changed DESC LIMIT 5;"
and
influx query --org redacted 'from(bucket:"homeassistant") |> range(start: -1h) |> filter(fn: (r) => r._measurement=="Wh" and r._field=="value" and r.entity_id=="pg_e_off_peak") |> aggregateWindow(every: 1m, fn: mean, createEmpty: false)'
However, after restarting HA, if I drill into the entity’s graph, it still shows intact history:
Is there another place where this data is stored? I thought maybe it was cached in my browser, so I tried a different one, but the data still showed.
This is related to this post that I’ve been attempting to troubleshoot: Negative values in Tariff Utility Meter while positive in parent source?