Logbook not showing any entries

Hey there,

I noticed that my logbook is not showing anything, only the loading circle circling around.
I changed my recorder to a mariadb instance running on my NAS. When changing over in one go HA got timeouts during the creation of the db, so I had to switch over piece by piece. At first I only included several entities to the recorder setting, later single domains. So I grew the dataset and restartet HA in between (and of course let it run for some time) until I completly removed all limitation of the recorder. Now everything should be kept in the mariadb.
But no matter if I look into a single entity or the logbook tab, I don’t see any entries.
Hope someone can help with that…

Best regards,
4nduril

well I dug a little deeper and found the following error log:

Logger: homeassistant.components.recorder.util
Source: components/recorder/util.py:221
Integration: Recorder (documentation, issues)
First occurred: 09:35:52 (2 occurrences)
Last logged: 09:37:29

Error executing query: (MySQLdb.OperationalError) (1176, "Key 'ix_states_metadata_id_last_updated_ts' doesn't exist in table 'states'") [SQL: WITH anon_1 AS (SELECT anon_2.context_id_bin AS context_id_bin FROM (SELECT events.context_id_bin AS context_id_bin FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.context_id_bin AS context_id_bin FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s)) AS anon_2 GROUP BY anon_2.context_id_bin) SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, CASE WHEN (JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) IS NULL) THEN CASE JSON_EXTRACT(CAST(states.attributes AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(states.attributes AS CHAR), %s)) END ELSE CASE JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s)) END END AS icon, %s AS context_only FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) LEFT OUTER JOIN states AS old_state ON states.old_state_id = old_state.state_id LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND old_state.state_id IS NOT NULL AND states.state != old_state.state AND states.state IS NOT NULL AND ((states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s) OR ((states_meta.entity_id LIKE %s) AND (state_attributes.shared_attrs NOT LIKE %s OR states.attributes NOT LIKE %s))) AND (states.last_updated_ts = states.last_changed_ts OR states.last_changed_ts IS NULL) AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s) UNION ALL SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only FROM anon_1 LEFT OUTER JOIN events FORCE INDEX (ix_events_context_id_bin) ON anon_1.context_id_bin = events.context_id_bin LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, %s AS icon, %s AS context_only FROM anon_1 LEFT OUTER JOIN states FORCE INDEX (ix_states_context_id_bin) ON anon_1.context_id_bin = states.context_id_bin LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id ORDER BY time_fired_ts] [parameters: (1686641800.972, 1686728151.882572, 14, '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."device_id"', '$."device_id"', '"3ebdce7f0f50ef4273f645934cfdbfab"', 1686641800.972, 1686728151.882572, 4355, 4352, 4360, 4351, 4361, 4359, 4354, 4353, None, None, None, None, 1686641800.972, 1686728151.882572, 14, '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."device_id"', '$."device_id"', '"3ebdce7f0f50ef4273f645934cfdbfab"', None, None, '$."icon"', '$."icon"', '$."icon"', '$."icon"', '$."icon"', None, 1686641800.972, 1686728151.882572, 'counter.%', 'proximity.%', 'sensor.%', 'sensor.%', '%"unit_of_measurement":%', '%"unit_of_measurement":%', 4355, 4352, 4360, 4351, 4361, 4359, 4354, 4353, None, None, None, '1', None, None, None, '1')] (Background on this error at: https://sqlalche.me/e/20/e3q8)
Error executing query: (MySQLdb.OperationalError) (1176, "Key 'ix_states_metadata_id_last_updated_ts' doesn't exist in table 'states'") [SQL: WITH anon_1 AS (SELECT anon_2.context_id_bin AS context_id_bin FROM (SELECT events.context_id_bin AS context_id_bin FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.context_id_bin AS context_id_bin FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s, %s)) AS anon_2 GROUP BY anon_2.context_id_bin) SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, CASE WHEN (JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) IS NULL) THEN CASE JSON_EXTRACT(CAST(states.attributes AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(states.attributes AS CHAR), %s)) END ELSE CASE JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s)) END END AS icon, %s AS context_only FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) LEFT OUTER JOIN states AS old_state ON states.old_state_id = old_state.state_id LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND old_state.state_id IS NOT NULL AND states.state != old_state.state AND states.state IS NOT NULL AND ((states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s) OR ((states_meta.entity_id LIKE %s) AND (state_attributes.shared_attrs NOT LIKE %s OR states.attributes NOT LIKE %s))) AND (states.last_updated_ts = states.last_changed_ts OR states.last_changed_ts IS NULL) AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s, %s) UNION ALL SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only FROM anon_1 LEFT OUTER JOIN events FORCE INDEX (ix_events_context_id_bin) ON anon_1.context_id_bin = events.context_id_bin LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, %s AS icon, %s AS context_only FROM anon_1 LEFT OUTER JOIN states FORCE INDEX (ix_states_context_id_bin) ON anon_1.context_id_bin = states.context_id_bin LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id ORDER BY time_fired_ts] [parameters: (1686641898.474, 1686728249.381481, 14, '$."entity_id"', '$."entity_id"', '"switch.jonas_dekolicht"', '"sensor.jonas_dekolicht_energy_totalstarttime"', '"sensor.jonas_dekolicht_last_restart_time"', '"sensor.jonas_dekolicht_mqtt_connect_count"', '"sensor.jonas_dekolicht_restart_reason"', '"sensor.jonas_dekolicht_ssid"', '"sensor.jonas_dekolicht_wifi_connect_count"', '"device_tracker.tasmota_jonas"', '"switch.tasmota_jonas_internet_access"', '"sensor.jonas_dekolicht_firmware_version"', '"sensor.jonas_dekolicht_ip"', '$."entity_id"', '$."entity_id"', '"switch.jonas_dekolicht"', '"sensor.jonas_dekolicht_energy_totalstarttime"', '"sensor.jonas_dekolicht_last_restart_time"', '"sensor.jonas_dekolicht_mqtt_connect_count"', '"sensor.jonas_dekolicht_restart_reason"', '"sensor.jonas_dekolicht_ssid"', '"sensor.jonas_dekolicht_wifi_connect_count"', '"device_tracker.tasmota_jonas"', '"switch.tasmota_jonas_internet_access"', '"sensor.jonas_dekolicht_firmware_version"', '"sensor.jonas_dekolicht_ip"', '$."device_id"', '$."device_id"', '"e88694d20c99073145801bed367a6a8e"', 1686641898.474, 1686728249.381481, 71, 840, 835, 837, 838, 839, 836, 480, 119, None, None, None, None, 1686641898.474, 1686728249.381481, 14 ... 12 parameters truncated ... '"sensor.jonas_dekolicht_ip"', '$."entity_id"', '$."entity_id"', '"switch.jonas_dekolicht"', '"sensor.jonas_dekolicht_energy_totalstarttime"', '"sensor.jonas_dekolicht_last_restart_time"', '"sensor.jonas_dekolicht_mqtt_connect_count"', '"sensor.jonas_dekolicht_restart_reason"', '"sensor.jonas_dekolicht_ssid"', '"sensor.jonas_dekolicht_wifi_connect_count"', '"device_tracker.tasmota_jonas"', '"switch.tasmota_jonas_internet_access"', '"sensor.jonas_dekolicht_firmware_version"', '"sensor.jonas_dekolicht_ip"', '$."device_id"', '$."device_id"', '"e88694d20c99073145801bed367a6a8e"', None, None, '$."icon"', '$."icon"', '$."icon"', '$."icon"', '$."icon"', None, 1686641898.474, 1686728249.381481, 'counter.%', 'proximity.%', 'sensor.%', 'sensor.%', '%"unit_of_measurement":%', '%"unit_of_measurement":%', 71, 840, 835, 837, 838, 839, 836, 480, 119, None, None, None, '1', None, None, None, '1')] (Background on this error at: https://sqlalche.me/e/20/e3q8)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1968, in _exec_single_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
          ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1176, "Key 'ix_states_metadata_id_last_updated_ts' doesn't exist in table 'states'")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 130, in session_scope
    yield session
  File "/usr/src/homeassistant/homeassistant/components/logbook/processor.py", line 169, in get_events
    execute_stmt_lambda_element(session, stmt, orm_rows=False)
  File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 221, in execute_stmt_lambda_element
    executed = session.connection().execute(stmt)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1413, in execute
    return meth(
           ^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/lambdas.py", line 605, in _execute_on_connection
    return connection._execute_clauseelement(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1637, in _execute_clauseelement
    ret = self._execute_context(
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1846, in _execute_context
    return self._exec_single_context(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1987, in _exec_single_context
    self._handle_dbapi_exception(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2344, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 1968, in _exec_single_context
    self.dialect.do_execute(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 920, in do_execute
    cursor.execute(statement, parameters)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
          ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 319, in _query
    db.query(q)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/connections.py", line 254, in query
    _mysql.connection.query(self, query)
sqlalchemy.exc.OperationalError: (MySQLdb.OperationalError) (1176, "Key 'ix_states_metadata_id_last_updated_ts' doesn't exist in table 'states'")
[SQL: WITH anon_1 AS 
(SELECT anon_2.context_id_bin AS context_id_bin 
FROM (SELECT events.context_id_bin AS context_id_bin 
FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id 
WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.context_id_bin AS context_id_bin 
FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) 
WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s)) AS anon_2 GROUP BY anon_2.context_id_bin)
 SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only 
FROM events LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id 
WHERE events.time_fired_ts > %s AND events.time_fired_ts < %s AND events.event_type_id IN (%s) AND (JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(events.event_data AS CHAR), %s) AS CHAR) IN (%s, %s, %s, %s, %s, %s, %s, %s) OR JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) IS NOT NULL AND CAST(JSON_EXTRACT(CAST(event_data.shared_data AS CHAR), %s) AS CHAR) IN (%s)) UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, CASE WHEN (JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) IS NULL) THEN CASE JSON_EXTRACT(CAST(states.attributes AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(states.attributes AS CHAR), %s)) END ELSE CASE JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s) WHEN 'null' THEN NULL ELSE JSON_UNQUOTE(JSON_EXTRACT(CAST(state_attributes.shared_attrs AS CHAR), %s)) END END AS icon, %s AS context_only 
FROM states FORCE INDEX (ix_states_metadata_id_last_updated_ts) LEFT OUTER JOIN states AS old_state ON states.old_state_id = old_state.state_id LEFT OUTER JOIN state_attributes ON states.attributes_id = state_attributes.attributes_id LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id 
WHERE states.last_updated_ts > %s AND states.last_updated_ts < %s AND old_state.state_id IS NOT NULL AND states.state != old_state.state AND states.state IS NOT NULL AND ((states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s AND states_meta.entity_id NOT LIKE %s) OR ((states_meta.entity_id LIKE %s) AND (state_attributes.shared_attrs NOT LIKE %s OR states.attributes NOT LIKE %s))) AND (states.last_updated_ts = states.last_changed_ts OR states.last_changed_ts IS NULL) AND states.metadata_id IN (%s, %s, %s, %s, %s, %s, %s, %s) UNION ALL SELECT events.event_id AS row_id, event_types.event_type AS event_type, CASE WHEN (event_data.shared_data IS NULL) THEN events.event_data ELSE event_data.shared_data END AS event_data, events.time_fired_ts AS time_fired_ts, events.context_id_bin AS context_id_bin, events.context_user_id_bin AS context_user_id_bin, events.context_parent_id_bin AS context_parent_id_bin, %s AS state, %s AS entity_id, %s AS icon, %s AS context_only 
FROM anon_1 LEFT OUTER JOIN events FORCE INDEX (ix_events_context_id_bin) ON anon_1.context_id_bin = events.context_id_bin LEFT OUTER JOIN event_types ON events.event_type_id = event_types.event_type_id LEFT OUTER JOIN event_data ON events.data_id = event_data.data_id UNION ALL SELECT states.state_id AS row_id, %s AS event_type, %s AS event_data, states.last_updated_ts AS time_fired_ts, states.context_id_bin AS context_id_bin, states.context_user_id_bin AS context_user_id_bin, states.context_parent_id_bin AS context_parent_id_bin, states.state AS state, states_meta.entity_id AS entity_id, %s AS icon, %s AS context_only 
FROM anon_1 LEFT OUTER JOIN states FORCE INDEX (ix_states_context_id_bin) ON anon_1.context_id_bin = states.context_id_bin LEFT OUTER JOIN states_meta ON states.metadata_id = states_meta.metadata_id ORDER BY time_fired_ts]
[parameters: (1686641800.972, 1686728151.882572, 14, '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."device_id"', '$."device_id"', '"3ebdce7f0f50ef4273f645934cfdbfab"', 1686641800.972, 1686728151.882572, 4355, 4352, 4360, 4351, 4361, 4359, 4354, 4353, None, None, None, None, 1686641800.972, 1686728151.882572, 14, '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."entity_id"', '$."entity_id"', '"binary_sensor.auto_vorhanden"', '"binary_sensor.bewegungsmelder_kleine_garage"', '"device_tracker.garagentor_kleine_garage"', '"update.garagentor_kleine_garage_firmware"', '"switch.garagentor_kleine_garage_internet_access"', '"switch.tor_bedienung_kleine_garage"', '"binary_sensor.tor_offen_kleine_garage"', '"binary_sensor.tor_zu_kleine_garage"', '$."device_id"', '$."device_id"', '"3ebdce7f0f50ef4273f645934cfdbfab"', None, None, '$."icon"', '$."icon"', '$."icon"', '$."icon"', '$."icon"', None, 1686641800.972, 1686728151.882572, 'counter.%', 'proximity.%', 'sensor.%', 'sensor.%', '%"unit_of_measurement":%', '%"unit_of_measurement":%', 4355, 4352, 4360, 4351, 4361, 4359, 4354, 4353, None, None, None, '1', None, None, None, '1')]
(Background on this error at: https://sqlalche.me/e/20/e3q8)

I tried to load these 2 in devices info tab. Somehow there seems to be a missing database entry…