Sensor data not displaying after a few hours

Hi

I have several temp sensors, a motion sensor and a combiner temp and humidity sensor going to a mysensors ESP8255 Wifi Gateway. I am running 0.40.0 HA, but after running for a few hours, the data from the sensors stop. Restarting HA get all working again for a few hours again. I have my error log below. Could someone give me some idea what maybe causing this.

Thanks Laurie

17-03-22 07:05:58 WARNING (Thread-4) [homeassistant.components.emulated_hue] Listen IP address not specified, auto-detected address is 192.168.1.150

17-03-22 07:05:58 WARNING (Thread-4) [homeassistant.components.emulated_hue] When targetting Google Home, listening port has to be port 80
17-03-22 07:06:07 WARNING (MainThread) [homeassistant.setup] Setup of sensor is taking over 10 seconds.
17-03-22 07:06:07 WARNING (MainThread) [homeassistant.setup] Setup of switch is taking over 10 seconds.
17-03-22 07:06:07 WARNING (MainThread) [homeassistant.setup] Setup of climate is taking over 10 seconds.
17-03-22 07:06:07 WARNING (MainThread) [homeassistant.setup] Setup of light is taking over 10 seconds.
17-03-22 07:06:08 WARNING (MainThread) [homeassistant.setup] Setup of device_tracker is taking over 10 seconds.
17-03-22 07:06:17 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=147 from 2017-03-20 14:10:37.131583)
17-03-22 07:06:18 WARNING (MainThread) [homeassistant.setup] Setup of recorder is taking over 10 seconds.
17-03-22 07:07:13 ERROR (Thread-12) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) database is locked [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 \nWHERE (states.domain IN (?, ?) OR states.last_changed = states.last_updated) AND states.last_updated > ? AND states.entity_id IN (?) AND states.last_updated < ? ORDER BY states.entity_id, states.last_updated’] [parameters: (‘thermostat’, ‘climate’, ‘2017-03-21 07:07:07.999011’, ‘sensor.temperature_sensor_67_5’, ‘2017-03-22 07:07:07.999011’)]
17-03-22 07:07:13 ERROR (Thread-12) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) database is locked [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 \nWHERE (states.domain IN (?, ?) OR states.last_changed = states.last_updated) AND states.last_updated > ? AND states.entity_id IN (?) AND states.last_updated < ? ORDER BY states.entity_id, states.last_updated’] [parameters: (‘thermostat’, ‘climate’, ‘2017-03-21 07:07:07.999011’, ‘sensor.temperature_sensor_67_5’, ‘2017-03-22 07:07:07.999011’)]
17-03-22 07:07:13 ERROR (Thread-12) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) database is locked [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 \nWHERE (states.domain IN (?, ?) OR states.last_changed = states.last_updated) AND states.last_updated > ? AND states.entity_id IN (?) AND states.last_updated < ? ORDER BY states.entity_id, states.last_updated’] [parameters: (‘thermostat’, ‘climate’, ‘2017-03-21 07:07:07.999011’, ‘sensor.temperature_sensor_67_5’, ‘2017-03-22 07:07:07.999011’)]
17-03-22 07:07:13 ERROR (Thread-12) [homeassistant.components.recorder.util] Error executing query: (sqlite3.OperationalError) database is locked [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 \nWHERE (states.domain IN (?, ?) OR states.last_changed = states.last_updated) AND states.last_updated > ? AND states.entity_id IN (?) AND states.last_updated < ? ORDER BY states.entity_id, states.last_updated’] [parameters: (‘thermostat’, ‘climate’, ‘2017-03-21 07:07:07.999011’, ‘sensor.temperature_sensor_67_5’, ‘2017-03-22 07:07:07.999011’)]
17-03-22 07:07:13 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 1182, in _execute_context
context)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/default.py”, line 470, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

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

Traceback (most recent call last):
File “/home/homeassistant/.homeassistant/deps/aiohttp/web_server.py”, line 62, in handle_request
resp = yield from self._handler(request)
File “/home/homeassistant/.homeassistant/deps/aiohttp/web.py”, line 270, in _handle
resp = yield from handler(request)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/ban.py”, line 58, in ban_middleware_handler
return (yield from handler(request))
File “/usr/lib/python3.4/asyncio/coroutines.py”, line 143, in coro
res = yield from res
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/http/init.py”, line 417, in handle
result = yield from result
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/history.py”, line 238, in get
end_time, entity_id, self.filters)
File “/usr/lib/python3.4/asyncio/futures.py”, line 388, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.4/asyncio/tasks.py”, line 286, in _wakeup
value = future.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/history.py”, line 78, in get_significant_states
query.order_by(States.entity_id, States.last_updated))
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/recorder/util.py”, line 63, in execute
(row.to_native() for row in qry)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/orm/query.py”, line 2790, in iter
return self._execute_and_instances(context)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/orm/query.py”, line 2813, in _execute_and_instances
result = conn.execute(querycontext.statement, self._params)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 945, in execute
return meth(self, multiparams, params)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/sql/elements.py”, line 263, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 1053, in _execute_clauseelement
compiled_sql, distilled_params
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 1189, in _execute_context
context)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 1393, in _handle_dbapi_exception
exc_info
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/util/compat.py”, line 203, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/util/compat.py”, line 186, in reraise
raise value.with_traceback(tb)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/base.py”, line 1182, in _execute_context
context)
File “/home/homeassistant/.homeassistant/deps/sqlalchemy/engine/default.py”, line 470, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked [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 \nWHERE (states.domain IN (?, ?) OR states.last_changed = states.last_updated) AND states.last_updated > ? AND states.entity_id IN (?) AND states.last_updated < ? ORDER BY states.entity_id, states.last_updated’] [parameters: (‘thermostat’, ‘climate’, ‘2017-03-21 07:07:07.999011’, ‘sensor.temperature_sensor_67_5’, ‘2017-03-22 07:07:07.999011’)]
17-03-22 07:07:19 WARNING (Thread-5) [netdisco.ssdp] Error fetching description at http://192.168.1.150:8300/description.xml
17-03-22 07:07:24 ERROR (MainThread) [homeassistant.core] Timer got out of sync. Resetting

I’m getting this as well now on 0.40.1. I only recently changed back to the built in DB from MySQL due to a runaway mysql DB file that I couldn’t shrink.

My error is below but I get the error of “No state history found.” on multiple sensors.

Error executing query: (sqlite3.OperationalError) database is locked

1 Like

This is a known issue with the mysensors ethernet gateway implementation in home assistant. It doesn’t reconnect if gateway gets disconnected. It has been fixed in the pymysensors library used to interface with mysensors, but I haven’t updated home assistant yet. It’s on my todo list.

https://github.com/home-assistant/home-assistant/issues/4891

The errors in your log seem unrelated to your described problem.

Ok, Thanks for letting me know. Do you have a timescale for implementation of this fix, as it is a show stopper for my system at the moment. I appreciate your work on this project.

No promises, but I’ll try to get it done until this or next release, ie 0.41 or 0.42.