Logbook no longer working

Hi all,

For about 2 weeks my log book has not been recording any data.

None of my entities are working, eg:

I don’t know whats changed. I even tried adding this into config.yaml just incase:

# Logbook (For History)    
logbook:

but still it shows up as:

Has anyone run into this problem?

What are you using for Recorder ? The built in database or something like MariaDb ?

If you are using the built in database then you should have a file called “home-assistant_v2.db” , if that has not updated in 2 weeks maybe it is corrupted - it can be deleted but you will lose any of your recent history. Restart HA after it has been deleted and see if there are any recorder errors when it comes back up.

Thanks so much for the reply!

I do not have recorder - but I have just added it. I just wanted to use the built in database which shows:

Should I still delete it if adding recorder doesn’t work?

Have you restarted HA after adding recorder ? Are there any errors when it starts up saying that recorder could not be setup ? After the restart are your history logs updating now ?

I restarted and got this error in logs:

2020-12-13 13:21:01 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 02:21:00.809574', '2020-12-13 02:21:00.809574', '336175a0ffee27a4cd6cbfce1c17de2d', None, None)]
(Background on this error at: http://sqlalche.me/e/13/4xp6)
2020-12-13 13:21:01 ERROR (Recorder) [homeassistant.components.recorder] Error saving events: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 02:21:00.809574', '2020-12-13 02:21:00.809574', '336175a0ffee27a4cd6cbfce1c17de2d', None, None)]
(Background on this error at: http://sqlalche.me/e/13/4xp6)

Looks like it’s corrupt. What version of HA are you using? A newer version auto-moves it to home-assistant.v2.db.corrupt. I suppose you could try to back up the valid parts, and then delete it and remake it.

I am using 0.118.5.
I just deleted it and it stills showing:

2020-12-13 14:08:13 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: (sqlite3.OperationalError) no such table: events
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 03:08:10.300602', '2020-12-13 03:08:10.300602', '168cd43e65d9605dc18f412f9d697ab1', None, None)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
2020-12-13 14:08:13 ERROR (Recorder) [homeassistant.components.recorder] Error in database connectivity during commit: (sqlite3.OperationalError) no such table: events
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 03:08:10.300602', '2020-12-13 03:08:10.300602', '168cd43e65d9605dc18f412f9d697ab1', None, None)]
(Background on this error at: http://sqlalche.me/e/13/e3q8). (retrying in 3 seconds)
2020-12-13 14:08:26 ERROR (Recorder) [homeassistant.components.recorder] Error executing query: (sqlite3.OperationalError) no such table: events
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 03:08:25.061797', '2020-12-13 03:08:25.061797', 'a49274fcedea8c208d1968a6b0d03de9', None, None)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
2020-12-13 14:08:26 ERROR (Recorder) [homeassistant.components.recorder] Error in database connectivity during commit: (sqlite3.OperationalError) no such table: events
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{}', 'LOCAL', '2020-12-13 03:08:25.061797', '2020-12-13 03:08:25.061797', 'a49274fcedea8c208d1968a6b0d03de9', None, None)]
(Background on this error at: http://sqlalche.me/e/13/e3q8). (retrying in 3 seconds)

Reboot too.

These are my steps:

  1. HA online
  2. Delete DB
  3. Restart HA in the UI

Should I be pulling the power or is that correct? Because I am still getting that error

Try this:

  • Delete DB
  • Restart HA
  • Restart HA
  • Post logs

Should be

  1. Stop HA
  2. Delete DB
  3. Start HA

Thanks all, that seemed to have fixed it :slight_smile: