SQL Error - Can't view sensor history

I’m facing the following issue currently:
Error executing query: (sqlite3.DatabaseError) database disk image is malformed [SQL: ‘SELECT states.state_id AS states_state_id, states.domain AS states_domain, states.entity_id AS states_entity_id, states.state AS states_state, states.attributes AS states_attributes, states.event_id AS states_event_id, states.last_changed AS states_last_changed, states.last_updated AS states_last_updated, states.created AS states_created \nFROM states JOIN (SELECT states.state_id AS max_state_id \nFROM states \nWHERE states.last_updated < ? AND states.entity_id IN (?) ORDER BY states.last_updated DESC\n LIMIT ? OFFSET ?) AS anon_1 ON states.state_id = anon_1.max_state_id \nWHERE states.domain NOT IN (?, ?) AND states.entity_id IN (?)’] [parameters: (‘2018-07-03 06:30:03.437000’, ‘sensor.air_pressure_livingroom’, 1, 0, ‘zone’, ‘scene’, ‘sensor.air_pressure_livingroom’)] (Background on this error at: http://sqlalche.me/e/4xp6)

And since this error raised, I can not view the sensor history anymor… Anyone know how to fix?

Stop the HA server. Delete your \hassio\config\home-assistant_v2.db file and restart. HA will create a new db file. You will lose your previous history.

You dont say what you are running HA on. If it is a raspi with an SD card and this happens again you might want to look at investing in a new good quality SD card and ensuring your power supply is capable of sustained 2.5A at 5V.

2 Likes

Can be closed, it’s fixed!

Click the “Solution” checkbox under my post.