Unable to access UI

Hi all,

I’m running hassio latest version on a Raspberry Pi 3B+. Everything was working fine up until this morning when all automations etc. stopped working. I tried to login to the UI, first using the app, then on my computer, both via my DuckDNS remote URL and the local IP address. No sign of the UI, on either, and the iOS app returns this error:

However, the odd thing is that all my devices show up and can be controlled in HomeKit. As they are connected via Hassio, when Hassio is down completely, they stop working. Access to the Pi via SSH is also working, so I tried rebooting, restoring to the last snapshot etc. with no change.

The logfile shows (apologies for length, but I don’t know what is relevant):

core-ssh:~# hassio homeassistant logs
session.flush()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2459, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2597, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
    uow,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
    insert,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1138, in _emit_insert_statements
    statement, params
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
    distilled_params,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('component_loaded', '{"component": "sonos"}', 'LOCAL', '2019-10-07 20:23:17.822301', '2019-10-07 20:24:21.007878', '47b6858993bd4bdf9d32c8d65dced75c', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)
2019-10-07 15:24:22 INFO (Thread-14) [roomba.roomba.Roomba] Received Roomba Data : wifistat, b'{"state":{"reported":{"signal":{"rssi":-39,"snr":51}}}}'
2019-10-07 15:24:23 INFO (Thread-14) [roomba.roomba.Roomba] updated state to: Charging
2019-10-07 15:24:23 ERROR (Recorder) [homeassistant.components.recorder.util] 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) VALUES (?, ?, ?, ?, ?, ?, ?)]
core-ssh:~# hassio homeassistant logs [B
compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
    uow,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
    insert,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1138, in _emit_insert_statements
    statement, params
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
    distilled_params,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{"entity_id": "automation.arrive_home", "old_state": null, "new_state": {"entity_id": "automation.arrive_home", "state": "on", "attributes": {"last_t ... (149 characters truncated) ... :00", "last_updated": "2019-10-07T20:27:53.950266+00:00", "context": {"id": "733266de8ec94ca3bc879e48dff6c889", "parent_id": null, "user_id": null}}}', 'LOCAL', '2019-10-07 20:27:53.950331', '2019-10-07 20:28:49.772230', '733266de8ec94ca3bc879e48dff6c889', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)
2019-10-07 15:28:49 ERROR (Recorder) [homeassistant.components.recorder.util] 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) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{"entity_id": "automation.mac_mini_off", "old_state": null, "new_state": {"entity_id": "automation.mac_mini_off", "state": "on", "attributes": {"last ... (152 characters truncated) ... :00", "last_updated": "2019-10-07T20:27:53.951399+00:00", "context": {"id": "57187572ac18468181ea9c5953415aec", "parent_id": null, "user_id": null}}}', 'LOCAL', '2019-10-07 20:27:53.951462', '2019-10-07 20:28:49.798531', '57187572ac18468181ea9c5953415aec', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)
2019-10-07 15:28:49 ERROR (Recorder) [homeassistant.components.recorder] Error saving event: <Event state_changed[L]: entity_id=automation.mac_mini_off, old_state=None, new_state=<state automation.mac_mini_off=on; last_triggered=2019-08-25T08:18:10.251330-05:00, id=1566739080567, friendly_name=Mac Mini off @ 2019-10-07T15:27:53.951399-05:00>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
sqlite3.DatabaseError: database disk image is malformed
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 346, in run
    session.flush()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2459, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2597, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 153, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2557, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute
    uow,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj
    insert,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1138, in _emit_insert_statements
    statement, params
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement
    distilled_params,
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context
    e, statement, parameters, cursor, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception
    util.raise_from_cause(sqlalchemy_exception, exc_info)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{"entity_id": "automation.mac_mini_off", "old_state": null, "new_state": {"entity_id": "automation.mac_mini_off", "state": "on", "attributes": {"last ... (152 characters truncated) ... :00", "last_updated": "2019-10-07T20:27:53.951399+00:00", "context": {"id": "57187572ac18468181ea9c5953415aec", "parent_id": null, "user_id": null}}}', 'LOCAL', '2019-10-07 20:27:53.951462', '2019-10-07 20:28:49.798531', '57187572ac18468181ea9c5953415aec', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)
2019-10-07 15:28:49 ERROR (Recorder) [homeassistant.components.recorder.util] 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) VALUES (?, ?, ?, ?, ?, ?, ?)]
[parameters: ('state_changed', '{"entity_id": "automation.guest_mode_on", "old_state": null, "new_state": {"entity_id": "automation.guest_mode_on", "state": "on", "attributes": {"la ... (155 characters truncated) ... :00", "last_updated": "2019-10-07T20:27:53.952505+00:00", "context": {"id": "4b10a63dbf864ebd966dd644c19eb74f", "parent_id": null, "user_id": null}}}', 'LOCAL', '2019-10-07 20:27:53.952567', '2019-10-07 20:28:49.826733', '4b10a63dbf864ebd966dd644c19eb74f', None)]
(Background on this error at: http://sqlalche.me/e/4xp6)
2019-10-07 15:28:49 ERROR (Recorder) [homeassistant.components.recorder] Error saving event: <Event state_changed[L]: entity_id=automation.guest_mode_on, old_state=None, new_state=<state automation.guest_mode_on=on; last_triggered=2019-09-24T19:55:01.445887-05:00, id=1567812834134, friendly_name=Guest mode on @ 2019-10-07T15:27:53.952505-05:00>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context
    cursor, statement, parameters, context
core-ssh:~# 

I’m finding this really frustrating! Can anyone point me in the right direction?

Massive thanks.

Looks like a database error.
‘sqlalchemy.exc.DatabaseError’

Maybe try to delete your db and start a new one.

Hi Burningstone,

Thanks for the input. Unfortunately I tried that, restarted and everything is still the same… I’m really hoping there’s a way to fix this without having to begin again with a fresh installation. :frowning:

I have a copy of my config file from a couple of weeks back when everything was working correctly. I’ve tried wiping the SD card and reinstalling then restoring my last snapshot, and the result was the same. Do you think the next option might be to wipe the card, reinstall hassio, install Samba and then use that to rebuild my config folder? Are there any files I shouldn’t copy across if I do it this way?

Thanks again!