This fixed the issue I was having with accumulated data not resetting. However, this didn’t fix the issue I’m having where the *_wh
entities are reporting insanely high values. That may just be an unrelated issue that I have to look at separately.
- Remove the relevant devices and entities.
Delete the IoTaWatt Integration
Delete the IoTWatt entities from the Energy dashboard.
- SSH into the machine running Home Assistant OS and stop Home Assistant
ssh [email protected]
ha core stop
- Create a backup copy of
home-assistant_v2.db
just in case we corrupt the database file.
cp /root/config/home-assistant_v2.db /root/config/home-assistant_v2.db.backup
- Open the database file in sqlite3
sqlite3 /root/config/home-assistant_v2.db
- Delete the old data
-- Use these to find the data to delete.
-- Change the search text to match your entities.
SELECT entity_id FROM states WHERE entity_id LIKE "sensor.main_line%";
SELECT statistic_id FROM statistics_meta WHERE statistic_id LIKE "sensor.main_line%";
-- Use these to delete the data.
-- Change the search text to match your entities.
DELETE FROM states WHERE entity_id LIKE "sensor.main_line_wh%";
DELETE FROM statistics_meta WHERE statistic_id LIKE "sensor.main_line_wh%";
- Exit the database
.quit
- Do this and set all the restore states for the accumulated entities to
0.0
. However, don’t do this while HA is running because it will keep restoring this file, ignoring your changes. Edit from SSH.
#vi, nano, or whatever you prefer.
vi /root/config/.storage/core.restore_state
#Then find any of the relevant entities and set their state parameter to 0.0
[/quote]
8. Use this command to check if the states were saved correctly.
cat /root/config/.storage/core.restore_state | grep accumulated -A 1
- Start Home Assistant (or just reboot)
ha core start
- Check the
core.restore_states
file again after starting HA to make sure that it wasn’t rebuilt without your changes.
cat /root/config/.storage/core.restore_state | grep accumulated -A 1
- Add the IoTaWatt device back to Home Assistant.
Settings > Devices & Services > Add Integration > IoTaWatt
- Add the IoTaWatt entities back to the Energy Dashboard.
Settings > Dashboards > Energy